diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
deleted file mode 100644
index 2213db0..0000000
--- a/.github/FUNDING.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-# These are supported funding model platforms
-custom: ["https://paypal.me/IbrahimBinAlshikh", "https://www.buymeacoffee.com/ibrahimdev"]
-ko_fi: ibrahimdev
diff --git a/.github/workflows/php80.yml b/.github/workflows/php80.yml
deleted file mode 100644
index e8842e0..0000000
--- a/.github/workflows/php80.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-name: Build PHP 8.0
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [ 8.0 ]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- tools: phpunit:8.5.13
-
- - name: Install Dependencies
- run: composer install --prefer-dist --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/php81.yaml b/.github/workflows/php81.yaml
new file mode 100644
index 0000000..fead114
--- /dev/null
+++ b/.github/workflows/php81.yaml
@@ -0,0 +1,26 @@
+name: Build PHP 8.1
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+jobs:
+ test:
+ name: Run Tests
+ uses: WebFiori/workflows/.github/workflows/test-php.yaml@main
+ with:
+ php-version: '8.1'
+
+ code-coverage:
+ name: Coverage
+ needs: test
+ uses: WebFiori/workflows/.github/workflows/coverage-codecov.yaml@main
+ with:
+ php-version: '8.1'
+ coverage-file: 'php-8.1-coverage.xml'
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+
+
+
diff --git a/.github/workflows/php81.yml b/.github/workflows/php81.yml
deleted file mode 100644
index b26e319..0000000
--- a/.github/workflows/php81.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-name: Build PHP 8.1
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [8.1]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- tools: phpunit:9.5.20, composer
-
-
- - name: Install Dependencies
- run: composer install --prefer-dist --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
-
- - name: SonarCloud
- uses: SonarSource/sonarcloud-github-action@master
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
diff --git a/.github/workflows/php82.yaml b/.github/workflows/php82.yaml
new file mode 100644
index 0000000..978033a
--- /dev/null
+++ b/.github/workflows/php82.yaml
@@ -0,0 +1,27 @@
+name: Build PHP 8.2
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+jobs:
+ test:
+ name: Run Tests
+ uses: WebFiori/workflows/.github/workflows/test-php.yaml@main
+ with:
+ php-version: '8.2'
+ phpunit-config: "tests/phpunit10.xml"
+
+ code-coverage:
+ name: Coverage
+ needs: test
+ uses: WebFiori/workflows/.github/workflows/coverage-codecov.yaml@main
+ with:
+ php-version: '8.2'
+ coverage-file: 'php-8.2-coverage.xml'
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+
+
+
diff --git a/.github/workflows/php82.yml b/.github/workflows/php82.yml
deleted file mode 100644
index 1807f41..0000000
--- a/.github/workflows/php82.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-name: Build PHP 8.2
-
-on:
- push:
- branches: [ master, dev ]
- pull_request:
- branches: [ master ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [8.2]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- tools: phpunit:9.5.20, composer
-
-
- - name: Install Dependencies
- run: composer install --prefer-dist --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
\ No newline at end of file
diff --git a/.github/workflows/php83.yaml b/.github/workflows/php83.yaml
new file mode 100644
index 0000000..8ecb808
--- /dev/null
+++ b/.github/workflows/php83.yaml
@@ -0,0 +1,45 @@
+name: Build PHP 8.3
+
+on:
+ push:
+ branches: [ main, dev ]
+ pull_request:
+ branches: [ main, dev ]
+env:
+ OPERATING_SYS: ubuntu-latest
+ PHP_VERSION: 8.3
+jobs:
+
+ test:
+ name: Run Tests
+ uses: WebFiori/workflows/.github/workflows/test-php.yaml@main
+ with:
+ php-version: '8.3'
+ phpunit-config: 'tests/phpunit10.xml'
+
+
+ code-coverage:
+ name: Coverage
+ needs: test
+ uses: WebFiori/workflows/.github/workflows/coverage-codecov.yaml@main
+ with:
+ php-version: '8.3'
+ coverage-file: 'php-8.3-coverage.xml'
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+
+ code-quality:
+ name: Code Quality
+ needs: test
+ uses: WebFiori/workflows/.github/workflows/quality-sonarcloud.yaml@main
+ with:
+ coverage-file: 'php-8.3-coverage.xml'
+ secrets:
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+
+ release-prod:
+ name: Prepare Production Release Branch / Publish Release
+ needs: [code-coverage, code-quality]
+ uses: WebFiori/workflows/.github/workflows/release-php.yaml@main
+ with:
+ branch: 'main'
diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml
deleted file mode 100644
index 8596f6d..0000000
--- a/.github/workflows/php83.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-name: Build PHP 8.3
-
-on:
- push:
- branches: [ master, dev ]
- pull_request:
- branches: [ master, dev ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [8.3]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- tools: phpunit:9.5.20, composer
-
- - name: Install Dependencies
- run: composer install --prefer-dist --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/php84.yaml b/.github/workflows/php84.yaml
new file mode 100644
index 0000000..1ce3097
--- /dev/null
+++ b/.github/workflows/php84.yaml
@@ -0,0 +1,27 @@
+name: Build PHP 8.4
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+jobs:
+ test:
+ name: Run Tests
+ uses: WebFiori/workflows/.github/workflows/test-php.yaml@main
+ with:
+ php-version: '8.4'
+ phpunit-config: "tests/phpunit10.xml"
+
+ code-coverage:
+ name: Coverage
+ needs: test
+ uses: WebFiori/workflows/.github/workflows/coverage-codecov.yaml@main
+ with:
+ php-version: '8.4'
+ coverage-file: 'php-8.4-coverage.xml'
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+
+
+
diff --git a/.github/workflows/php84.yml b/.github/workflows/php84.yml
deleted file mode 100644
index dc0dcca..0000000
--- a/.github/workflows/php84.yml
+++ /dev/null
@@ -1,65 +0,0 @@
-name: Build PHP 8.4
-
-on:
- push:
- branches: [ master, dev ]
- pull_request:
- branches: [ master, dev ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [8.4]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- tools: phpunit:9.5.20, composer
-
- - name: Shutdown Ubuntu MySQL
- run: sudo service mysql stop
-
- - name: Install Dependencies
- run: composer install --prefer-dist --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
-
- - name: SonarCloud Code Scan
- uses: sonarsource/sonarqube-scan-action@v4
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
-
- release_prod:
- name: Prepare Production Release Branch / Publish Release
- needs:
- - "test"
- runs-on: ubuntu-latest
- if: github.ref == 'refs/heads/master'
- steps:
- - uses: actions/checkout@v4
- - uses: google-github-actions/release-please-action@v3
- with:
- release-type: php
- config-file: release-please-config.json
- token: ${{ secrets.GITHUB_TOKEN }}
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 6a9b5bc..bbb22e2 100644
--- a/README.md
+++ b/README.md
@@ -3,10 +3,10 @@ A set of classes that provide basic web pages creation utilities in addition to
-
+
-
+
@@ -35,15 +35,15 @@ A set of classes that provide basic web pages creation utilities in addition to
## Supported PHP Versions
| Build Status |
|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
-|
|
-|
|
-|
|
-|
|
-|
|
-|
|
-|
|
-|
|
-|
|
+|
|
+|
|
+|
|
+|
|
+
+
+|
|
+|
|
+|
|
## Features
* Ability to create custom HTML UI Elements in OOP approach.
diff --git a/WebFiori/UI/HTMLNode.php b/WebFiori/UI/HTMLNode.php
index e28f17b..20f1e5f 100644
--- a/WebFiori/UI/HTMLNode.php
+++ b/WebFiori/UI/HTMLNode.php
@@ -26,7 +26,11 @@ class HTMLNode implements Countable, Iterator {
/**
* A constant that indicates a node is of type comment.
*
+ * Used when creating comment nodes or checking node types.
+ * Comment nodes are rendered as in HTML output.
+ *
* @var string
+ * @see isComment() To check if node is comment type
*/
const COMMENT_NODE = '#COMMENT';
/**
@@ -79,8 +83,12 @@ class HTMLNode implements Countable, Iterator {
];
/**
* A constant that indicates a node is of type text.
+ *
+ * Used for nodes that contain only text content without HTML tags.
+ * Text nodes can have HTML entities escaped for security.
+ *
* @var string
- *
+ * @see isTextNode() To check if node is text type
*/
const TEXT_NODE = '#TEXT';
/**
@@ -230,10 +238,9 @@ class HTMLNode implements Countable, Iterator {
* [0-9], ':', '.' and '-'.
*
*
- * @param $attrs array An optional array that contains node attributes.
+ * @param array $attrs An optional array that contains node attributes.
*
- * @throws InvalidNodeNameException The method will throw an exception if given node
- * name is not valid.
+ * @throws InvalidNodeNameException When the provided node name is invalid, empty, or contains illegal characters
*/
public function __construct(string $name = 'div', array $attrs = []) {
$this->null = null;
@@ -380,7 +387,7 @@ public function addCommentNode(string $text) {
*
* @param string $text The text that will be in the node.
*
- * @param bool $escHtmlEntities If set to true, the method will
+ * @param bool $esc If set to true, HTML entities will be escaped in text content.HtmlEntities If set to true, the method will
* replace the characters '<', '>' and
* '&' with the following HTML entities: '<', '>' and '&'
* in the given text. Default is true.
@@ -409,6 +416,14 @@ public function addTextNode(string $text, bool $escHtmlEntities = true) {
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function anchor(string|HTMLNode $body, array $attributes = []) : HTMLNode {
@@ -516,6 +531,14 @@ public function asCode(array $formattingOptions = HTMLNode::DEFAULT_CODE_FORMAT)
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function br() : HTMLNode {
@@ -672,6 +695,14 @@ public function codeSnippet(string $title, $code, array $attributes = []) : HTML
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function comment(string $txt) {
@@ -746,7 +777,7 @@ public static function createComment(string $text) : HTMLNode {
* @param string $nodeText The text that will be inserted in the body
* of the node.
*
- * @param bool $escHtmlEntities If set to true, the method will
+ * @param bool $esc If set to true, HTML entities will be escaped in text content.HtmlEntities If set to true, the method will
* replace the characters '<', '>' and
* '&' with the following HTML entities: '<', '>' and '&'
* in the given text.
@@ -840,23 +871,30 @@ public function form(array $attributes = []) : HTMLNode {
/**
* Create HTML from template or HTML file.
+ *
+ * This is a factory method that creates HTMLNode instances from external files.
+ * Supports both HTML templates with slots ({{variable}}) and PHP templates with variables.
*
- * @param string $absPath The absolute path to HTML document. This can
- * also be the path to PHP template file.
+ * @param string $absPath Absolute path to template file (.html or .php extension)
+ * @param array $slotsOrVars For HTML templates: slot values. For PHP templates: variables to extract
*
- * @param array $slotsOrVars An associative array that have slots values of
- * the template. This also can be the values that will be passed to PHP
- * template.
+ * @return array|HeadNode|HTMLDoc|HTMLNode Return type depends on template structure:
+ * - HTMLDoc: Complete HTML document with DOCTYPE, html, head, body
+ * - HTMLNode: Single root element template
+ * - array: Multiple root elements (fragment)
+ * - HeadNode: If template contains only head section
*
- * @return array|HeadNode|HTMLDoc|HTMLNode If the given template represents HTML document,
- * an object of type 'HTMLDoc' is returned. If the given code has multiple top level nodes
- * (e.g. '<div></div><div></div>'),
- * an array that contains an objects of type 'HTMLNode' is returned. If the
- * given code has one top level node, an object of type 'HTMLNode' is returned.
- * Note that it is possible that the method will return an instance which
- * is a subclass of the class 'HTMLNode'.
- *
- * @throws TemplateNotFoundException
+ * @throws TemplateNotFoundException When template file does not exist
+ * @throws InvalidNodeNameException When template contains invalid HTML elements
+ *
+ * @example
+ * ```php
+ * // HTML template with slots
+ * $node = HTMLNode::fromFile('page.html', ['title' => 'My Page']);
+ *
+ * // PHP template with variables
+ * $node = HTMLNode::fromFile('list.php', ['items' => $dataArray]);
+ * ```
*/
public static function fromFile(string $absPath, array $slotsOrVars = []) {
$compiler = new TemplateCompiler($absPath, $slotsOrVars);
@@ -942,9 +980,9 @@ public function getAttributeValue(string $attrName) {
* @param int $index The position of the child node. This must be an integer
* value starting from 0.
*
- * @return HTMLNode|null If the child does exist, the method will return
- * an object of type 'HTMLNode'. If no element was found, the method will
- * return null.
+ * @return HTMLNode|null Return value depends on index validity:
+ * - HTMLNode: When child exists at the specified index
+ * - null: When index is out of bounds (< 0 or >= childrenCount())
*
*
*/
@@ -983,10 +1021,11 @@ public function getChildByAttributeValue(string $attrName, string $attrVal) {
/**
* Returns a child node given its ID.
*
- * @param string $val The ID of the child.
+ * @param string $val The value to search for. The ID of the child.
*
- * @return null|HTMLNode The method returns an object of type HTMLNode
- * if found. If no node has the given ID, the method will return null.
+ * @return HTMLNode|null Return value depends on search result:
+ * - HTMLNode: When a child with the specified ID is found
+ * - null: When no child has the given ID or ID is empty
*
*
*/
@@ -1002,7 +1041,7 @@ public function getChildByID(string $val) {
* If the given tag name is empty string or the node has no children which has
* the given tag name, the returned list will be empty.
*
- * @param string $val The name of the tag (such as 'div' or 'a').
+ * @param string $val The value to search for. The name of the tag (such as 'div' or 'a').
*
* @return LinkedList A linked list that contains all child nodes which has the given
* tag name.
@@ -1229,7 +1268,7 @@ public function hasAttribute($attrName) : bool {
/**
* Checks if a given node is a direct child of the instance.
*
- * @param HTMLNode $node The node that will be checked.
+ * @param HTMLNode $node The HTML node to process. The node that will be checked.
*
* @return bool true is returned if the node is a child
* of the instance. false if not. Also, if the current instance is a
@@ -1249,6 +1288,14 @@ public function hasChild($node) : bool {
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function hr() : HTMLNode {
@@ -1515,6 +1562,14 @@ public function label($body, array $attributes = []) : HTMLNode {
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function li($itemBody, array $attributes = []) : HTMLNode {
@@ -1632,7 +1687,7 @@ public function open() : string {
*
* @param array $attributes An array that contains extra attributes for the paragraph.
*
- * @param bool $escEntities If set to true, the method will
+ * @param bool $esc If set to true, HTML entities will be escaped in text content.Entities If set to true, the method will
* replace the characters '<', '>' and
* '&' with the following HTML entities: '<', '>' and '&'
* in the given text. Default is true.
@@ -1892,7 +1947,7 @@ public function setAttributes(array $attrsArr) : HTMLNode {
/**
* Sets the value of the attribute 'class' of the node.
*
- * @param string $val The name of the class.
+ * @param string $val The value to search for. The name of the class.
*
* @param bool $override If this parameter is set to false and the node
* has a class already set, the given class name will be appended to the
@@ -1918,7 +1973,7 @@ public function setClassName(string $val, bool $override = true) : HTMLNode {
*
* This only applies to text node.
*
- * @param bool $esc
+ * @param bool $esc If set to true, HTML entities will be escaped in text content.
*/
public function setEscapeEntities(bool $esc) {
if ($this->isTextNode()) {
@@ -1979,11 +2034,19 @@ public function setIsVoidNode(bool $bool) {
/**
* Sets the value of the attribute 'name' of the node.
*
- * @param string $val The value to set.
+ * @param string $val The value to search for. The value to set.
*
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function setName(string $val) : HTMLNode {
@@ -2045,7 +2108,7 @@ public function setNodeName(string $name) : bool {
/**
* Sets the value of the attribute 'style' of the node.
*
- * @param array $cssStyles An associative array of CSS declarations. The keys of the array should
+ * @param array $cssStyles Associative array of CSS declarations. Keys are CSS property names (e.g., "color", "background-color"), values are CSS values (e.g., "red", "#ffffff"). The keys of the array should
* be the names of CSS Properties and the values should be the values of
* the attributes (e.g. 'color'=>'white').
*
@@ -2056,6 +2119,14 @@ public function setNodeName(string $name) : bool {
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function setStyle(array $cssStyles, bool $override = false) : HTMLNode {
@@ -2106,6 +2177,14 @@ public function setStyle(array $cssStyles, bool $override = false) : HTMLNode {
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function setTabIndex(int $val) : HTMLNode {
@@ -2120,7 +2199,7 @@ public function setTabIndex(int $val) : HTMLNode {
* @param string $text The text to set. If the node is not a text node or
* a comment node, the value will never be set.
*
- * @param bool $escHtmlEntities If set to true, the method will
+ * @param bool $esc If set to true, HTML entities will be escaped in text content.HtmlEntities If set to true, the method will
* replace the characters '<', '>' and
* '&' with the following HTML entities: '<', '>' and '&'
* in the given text. Default is true. Ignored in case the node type is comment.
@@ -2128,6 +2207,14 @@ public function setTabIndex(int $val) : HTMLNode {
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function setText(string $text, bool $escHtmlEntities = true) : HTMLNode {
@@ -2145,7 +2232,7 @@ public function setText(string $text, bool $escHtmlEntities = true) : HTMLNode {
/**
* Sets the value of the attribute 'title' of the node.
*
- * @param string $val The value to set. From MDN: Contains a
+ * @param string $val The value to search for. The value to set. From MDN: Contains a
* text representing advisory information related to the element
* it belongs to. Such information can typically, but not necessarily,
* be presented to the user as a tooltip.
@@ -2153,6 +2240,14 @@ public function setText(string $text, bool $escHtmlEntities = true) : HTMLNode {
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function setTitle(string $val) : HTMLNode {
@@ -2174,11 +2269,19 @@ public function setUseForwardSlash(bool $hasForward) {
/**
* Sets the value of the attribute 'dir' of the node.
*
- * @param string $val The value to set. It can be 'ltr' or 'rtl'.
+ * @param string $val The value to search for. The value to set. It can be 'ltr' or 'rtl'.
*
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function setWritingDir(string $val) : HTMLNode {
@@ -2213,7 +2316,7 @@ public function table(array $attributes = []) : HTMLNode {
*
* @param string $txt The text that will be in the node.
*
- * @param bool $escEntities If set to true, the method will
+ * @param bool $esc If set to true, HTML entities will be escaped in text content.Entities If set to true, the method will
* replace the characters '<', '>' and
* '&' with the following HTML entities: '<', '>' and '&'
* in the given text. Default is true.
@@ -2221,6 +2324,14 @@ public function table(array $attributes = []) : HTMLNode {
* @return HTMLNode The method will return the instance that this
* method is called on.
*
+ * @example
+ * ```php
+ * $node->setStyle([
+ * "color" => "red",
+ * "background-color" => "#ffffff",
+ * "margin" => "10px 5px"
+ * ]);
+ * ```
*
*/
public function text(string $txt, bool $escEntities = true) : HTMLNode {
@@ -2369,9 +2480,10 @@ private function addTab() {
$this->tabCount += 1;
}
/**
+ * Returns the closing tag of the node as formatted code.
*
* @param array $FO Formatting options.
- * @return string
+ * @return string The closing tag as formatted HTML code.
*
*/
private function closeAsCode(array $FO) : string {
@@ -2386,8 +2498,8 @@ private function closeAsCode(array $FO) : string {
}
/**
*
- * @param string $val
- * @param LinkedList $chNodes
+ * @param string $val The value to search for.
+ * @param LinkedList $chNodes The list of child nodes.
* @return null|HTMLNode Description
*/
private function getChildByIDHelper(string $val, ?LinkedList $chNodes) {
@@ -2419,9 +2531,9 @@ private function getChildByIDHelper(string $val, ?LinkedList $chNodes) {
}
/**
*
- * @param string $val
- * @param LinkedList $chList
- * @param LinkedList $list
+ * @param string $val The value to search for.
+ * @param LinkedList $chList The list of children to search.
+ * @param LinkedList $list The list to populate with results.
* @return LinkedList
*/
private function getChildrenByTagHelper(string $val,LinkedList $chList, LinkedList $list) : LinkedList {
@@ -2490,9 +2602,10 @@ private function nodeFromArrayHelper(array $arr) : HTMLNode {
return $node;
}
/**
+ * Returns the closing tag of the node as formatted code.
*
* @param array $FO Formatting options.
- * @return string
+ * @return string The closing tag as formatted HTML code.
*
*/
private function openAsCode(array $FO) : string {
@@ -2563,7 +2676,7 @@ private function popNodeAsCode(array $FO) {
}
/**
*
- * @param HTMLNode $node
+ * @param HTMLNode $node The HTML node to process.
*/
private function pushNode(HTMLNode $node) {
if ($node->isTextNode()) {
@@ -2619,7 +2732,7 @@ private function pushNode(HTMLNode $node) {
}
}
/**
- * @param HTMLNode $node
+ * @param HTMLNode $node The HTML node to process.
*
* @param array $FO Formatting options.
*
diff --git a/WebFiori/UI/HeadNode.php b/WebFiori/UI/HeadNode.php
index 297144a..18c7ac0 100644
--- a/WebFiori/UI/HeadNode.php
+++ b/WebFiori/UI/HeadNode.php
@@ -1083,7 +1083,7 @@ private function addChildHelper(HTMLNode $node) {
/**
*
* @param HTMLNode $node
- * @param $otherAttrs
+ * @param array $otherAttrs Additional attributes to set for the node.
*/
private function cssJsInsertHelper(HTMLNode $node, $otherAttrs) {
if ($node->getNodeName() == 'link') {
diff --git a/WebFiori/UI/TemplateCompiler.php b/WebFiori/UI/TemplateCompiler.php
index c797ddc..e910618 100644
--- a/WebFiori/UI/TemplateCompiler.php
+++ b/WebFiori/UI/TemplateCompiler.php
@@ -47,8 +47,9 @@ class TemplateCompiler {
* value of each key represents the value of the variable inside the template.
* This parameter is applicable only if the template is a PHP file.
*
- * @throws TemplateNotFoundException If no file is found which has given path.
- * @throws InvalidNodeNameException
+ * @throws InvalidArgumentException When template path is empty
+ * @throws TemplateNotFoundException When template file is not found
+ * @throws InvalidNodeNameException When template contains invalid HTML elements
*/
public function __construct(string $templatePath, array $vars = []) {
$trimmedPath = trim($templatePath);