From 77a7eb18f003dba0b0d82f969e93f2896947121e Mon Sep 17 00:00:00 2001 From: Gilles Paquette Date: Sun, 23 Aug 2020 18:30:20 +0000 Subject: [PATCH] fixed #229 - Added documentation to reflect read only property --- .php_cs.dist | 3 ++- src/PHPHtmlParser/Dom/Node/AbstractNode.php | 13 ++++++------- src/PHPHtmlParser/Dom/Node/ArrayNode.php | 8 ++++++++ src/PHPHtmlParser/Dom/Node/HtmlNode.php | 7 +++++++ src/PHPHtmlParser/Dom/Node/InnerNode.php | 8 ++++++++ src/PHPHtmlParser/Dom/Node/LeafNode.php | 9 +++++++++ src/PHPHtmlParser/Dom/Node/TextNode.php | 7 +++++++ tests/Node/HtmlTest.php | 2 +- 8 files changed, 48 insertions(+), 9 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 56af284..2ead719 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -90,6 +90,7 @@ return PhpCsFixer\Config::create() 'method', 'param', 'property', + 'property-read', 'return', 'throws', 'type', @@ -100,7 +101,7 @@ return PhpCsFixer\Config::create() 'phpdoc_indent' => true, 'phpdoc_inline_tag' => true, 'phpdoc_no_access' => true, - 'phpdoc_no_alias_tag' => true, + 'phpdoc_no_alias_tag' => false, 'phpdoc_no_package' => true, 'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_order' => true, diff --git a/src/PHPHtmlParser/Dom/Node/AbstractNode.php b/src/PHPHtmlParser/Dom/Node/AbstractNode.php index a2c2927..897445b 100644 --- a/src/PHPHtmlParser/Dom/Node/AbstractNode.php +++ b/src/PHPHtmlParser/Dom/Node/AbstractNode.php @@ -17,13 +17,12 @@ /** * Dom node object. * - * @property string $outerhtml - * @property string $innerhtml - * @property string $text - * @property int $prev - * @property int $next - * @property Tag $tag - * @property InnerNode $parent + * @property-read string $outerhtml + * @property-read string $innerhtml + * @property-read string $innerText + * @property-read string $text + * @property-read Tag $tag + * @property-read InnerNode $parent */ abstract class AbstractNode { diff --git a/src/PHPHtmlParser/Dom/Node/ArrayNode.php b/src/PHPHtmlParser/Dom/Node/ArrayNode.php index fb8ed4c..87e8bd5 100644 --- a/src/PHPHtmlParser/Dom/Node/ArrayNode.php +++ b/src/PHPHtmlParser/Dom/Node/ArrayNode.php @@ -7,10 +7,18 @@ use ArrayIterator; use Countable; use IteratorAggregate; +use PHPHtmlParser\Dom\Tag; /** * Dom node object which will allow users to use it as * an array. + * + * @property-read string $outerhtml + * @property-read string $innerhtml + * @property-read string $innerText + * @property-read string $text + * @property-read Tag $tag + * @property-read InnerNode $parent */ abstract class ArrayNode extends AbstractNode implements IteratorAggregate, Countable { diff --git a/src/PHPHtmlParser/Dom/Node/HtmlNode.php b/src/PHPHtmlParser/Dom/Node/HtmlNode.php index 0d78b8f..2acb259 100644 --- a/src/PHPHtmlParser/Dom/Node/HtmlNode.php +++ b/src/PHPHtmlParser/Dom/Node/HtmlNode.php @@ -10,6 +10,13 @@ /** * Class HtmlNode. + * + * @property-read string $outerhtml + * @property-read string $innerhtml + * @property-read string $innerText + * @property-read string $text + * @property-read Tag $tag + * @property-read InnerNode $parent */ class HtmlNode extends InnerNode { diff --git a/src/PHPHtmlParser/Dom/Node/InnerNode.php b/src/PHPHtmlParser/Dom/Node/InnerNode.php index 911e10a..448057a 100644 --- a/src/PHPHtmlParser/Dom/Node/InnerNode.php +++ b/src/PHPHtmlParser/Dom/Node/InnerNode.php @@ -4,6 +4,7 @@ namespace PHPHtmlParser\Dom\Node; +use PHPHtmlParser\Dom\Tag; use PHPHtmlParser\Exceptions\ChildNotFoundException; use PHPHtmlParser\Exceptions\CircularException; use PHPHtmlParser\Exceptions\LogicalException; @@ -11,6 +12,13 @@ /** * Inner node of the html tree, might have children. + * + * @property-read string $outerhtml + * @property-read string $innerhtml + * @property-read string $innerText + * @property-read string $text + * @property-read Tag $tag + * @property-read InnerNode $parent */ abstract class InnerNode extends ArrayNode { diff --git a/src/PHPHtmlParser/Dom/Node/LeafNode.php b/src/PHPHtmlParser/Dom/Node/LeafNode.php index 7a2a738..f74414a 100644 --- a/src/PHPHtmlParser/Dom/Node/LeafNode.php +++ b/src/PHPHtmlParser/Dom/Node/LeafNode.php @@ -4,8 +4,17 @@ namespace PHPHtmlParser\Dom\Node; +use PHPHtmlParser\Dom\Tag; + /** * Class LeafNode. + * + * @property-read string $outerhtml + * @property-read string $innerhtml + * @property-read string $innerText + * @property-read string $text + * @property-read Tag $tag + * @property-read InnerNode $parent */ abstract class LeafNode extends AbstractNode { diff --git a/src/PHPHtmlParser/Dom/Node/TextNode.php b/src/PHPHtmlParser/Dom/Node/TextNode.php index a5bd934..1c8b646 100644 --- a/src/PHPHtmlParser/Dom/Node/TextNode.php +++ b/src/PHPHtmlParser/Dom/Node/TextNode.php @@ -9,6 +9,13 @@ /** * Class TextNode. + * + * @property-read string $outerhtml + * @property-read string $innerhtml + * @property-read string $innerText + * @property-read string $text + * @property-read Tag $tag + * @property-read InnerNode $parent */ class TextNode extends LeafNode { diff --git a/tests/Node/HtmlTest.php b/tests/Node/HtmlTest.php index 153f7da..592003b 100755 --- a/tests/Node/HtmlTest.php +++ b/tests/Node/HtmlTest.php @@ -334,7 +334,7 @@ public function testInnerText() $node->addChild($anode); $node->addChild($span_node); - $this->assertEquals($node->innerText(), '123 456789 101112'); + $this->assertEquals($node->innerText, '123 456789 101112'); } public function testTextLookInChildrenAndNoChildren()