Skip to content

Commit

Permalink
fix scrutinizer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xinningsu committed Jul 22, 2019
1 parent 21eb9c5 commit 6e010a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/HtmlQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1102,11 +1102,9 @@ protected function validateNodes($nodes)
{
if (empty($nodes)) {
$nodes = [];
} elseif ($nodes instanceof DOMNode) {
$nodes = [$nodes];
}

if (!is_array($nodes) && !($nodes instanceof Traversable)) {
} elseif ($nodes instanceof Traversable) {
$nodes = iterator_to_array($nodes);
} elseif ($nodes instanceof DOMNode || !is_array($nodes)) {
$nodes = [$nodes];
}

Expand Down
6 changes: 6 additions & 0 deletions tests/HtmlQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public function testValidateNodes()
$validateNodes(array_merge($nodes, $nodes))
);

$fruits = $hq->find('.fruit');
$this->assertEquals(
$fruits->getNodes(),
$validateNodes($fruits)
);

$exception = null;
try {
$validateNodes([1]);
Expand Down

0 comments on commit 6e010a4

Please sign in to comment.