Skip to content

Commit 1fd9741

Browse files
authored
Resolves Problem with PHP 7.2 Throwing Error on count
Problem: Currently PHP 7.2 throws an error if count is used on a non-countable object. Resolution: Check for variable Countableness. Change: Check variable is an instanceof Countable.
1 parent 9663472 commit 1fd9741

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)