Skip to content

Commit 72f8510

Browse files
authored
Merge pull request paquettg#126 from Upperfoot/patch-1
Resolves Problem with PHP 7.2 Throwing Error on count
2 parents e85e379 + 1fd9741 commit 72f8510

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/PHPHtmlParser/Selector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHPHtmlParser\Dom\InnerNode;
77
use PHPHtmlParser\Dom\LeafNode;
88
use PHPHtmlParser\Exceptions\ChildNotFoundException;
9+
use Countable;
910

1011
/**
1112
* Class Selector
@@ -168,7 +169,9 @@ protected function parseSelectorString($selector)
168169
protected function seek(array $nodes, array $rule, array $options)
169170
{
170171
// XPath index
171-
if (count($rule['tag']) > 0 &&
172+
if ($rule['tag'] instanceof Countable &&
173+
count($rule['tag']) > 0 &&
174+
$rule['key'] instanceof Countable &&
172175
count($rule['key']) > 0 &&
173176
is_numeric($rule['key'])
174177
) {

0 commit comments

Comments
 (0)