Conditions | 5 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
37 | 548 | public function getIterator(): \Generator |
|
38 | { |
||
39 | 548 | $stack = [$this->node]; |
|
40 | 548 | $index = 0; |
|
41 | |||
42 | 548 | while ($stack) { |
|
|
|||
43 | 548 | $node = \array_pop($stack); |
|
44 | |||
45 | 548 | yield $index++ => $node; |
|
46 | |||
47 | // Push all children onto the stack in reverse order |
||
48 | 546 | $child = $node->lastChild(); |
|
49 | 546 | while ($child !== null) { |
|
50 | 536 | if (! $this->blocksOnly || $child instanceof AbstractBlock) { |
|
51 | 536 | $stack[] = $child; |
|
52 | } |
||
53 | |||
54 | 536 | $child = $child->previous(); |
|
55 | } |
||
59 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.