Skip to content

Commit 9ce023b

Browse files
committed
Refactoring
1 parent 8bf35cd commit 9ce023b

File tree

6 files changed

+13
-5
lines changed

6 files changed

+13
-5
lines changed

src/PHPHtmlParser/Content.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function copyByToken(string $token, bool $char = false, bool $escape = fa
219219
*
220220
* @param string $string
221221
* @param bool $copy
222-
* @return $this|string
222+
* @return Content|string
223223
*/
224224
public function skip(string $string, bool $copy = false)
225225
{
@@ -242,7 +242,7 @@ public function skip(string $string, bool $copy = false)
242242
*
243243
* @param string $token
244244
* @param bool $copy
245-
* @return null|string
245+
* @return Content|string
246246
* @uses $this->skip()
247247
*/
248248
public function skipByToken(string $token, bool $copy = false)

src/PHPHtmlParser/Dom/AbstractNode.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* @property string outerhtml
1616
* @property string innerhtml
1717
* @property string text
18+
* @property int prev
19+
* @property int next
1820
* @property \PHPHtmlParser\Dom\Tag tag
1921
* @property InnerNode parent
2022
*/

src/PHPHtmlParser/Dom/HtmlNode.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class HtmlNode extends InnerNode
1414

1515
/**
1616
* Remembers what the innerHtml was if it was scanned previously.
17+
*
18+
* @var string
1719
*/
1820
protected $innerHtml = null;
1921

src/PHPHtmlParser/Dom/InnerNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function firstChild(): AbstractNode
367367
}
368368

369369
reset($this->children);
370-
$key = key($this->children);
370+
$key = (int) key($this->children);
371371

372372
return $this->getChild($key);
373373
}

src/PHPHtmlParser/Dom/MockNode.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ class MockNode extends InnerNode
1616
*/
1717
public function innerHtml(): string
1818
{
19+
return '';
1920
}
2021

2122
/**
2223
* Mock of outer html.
2324
*/
2425
public function outerHtml(): string
2526
{
27+
return '';
2628
}
2729

2830
/**
2931
* Mock of text.
3032
*/
3133
public function text(): string
3234
{
35+
return '';
3336
}
3437

3538
/**

src/PHPHtmlParser/Finder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPHtmlParser;
44

55
use PHPHtmlParser\Dom\AbstractNode;
6+
use PHPHtmlParser\Dom\InnerNode;
67

78
class Finder
89
{
@@ -26,7 +27,7 @@ public function __construct($id)
2627
*/
2728
public function find(AbstractNode $node)
2829
{
29-
if (!$node->id()) {
30+
if (!$node->id() && $node instanceof InnerNode) {
3031
return $this->find($node->firstChild());
3132
}
3233

@@ -51,4 +52,4 @@ public function find(AbstractNode $node)
5152

5253
return false;
5354
}
54-
}
55+
}

0 commit comments

Comments
 (0)