| Conditions | 5 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 37 | 432 | public function getIterator(): \Generator |
|
| 38 | { |
||
| 39 | 432 | $stack = [$this->node]; |
|
| 40 | 432 | $index = 0; |
|
| 41 | |||
| 42 | 432 | while ($stack) { |
|
|
|
|||
| 43 | 432 | $node = \array_pop($stack); |
|
| 44 | |||
| 45 | 432 | yield $index++ => $node; |
|
| 46 | |||
| 47 | // Push all children onto the stack in reverse order |
||
| 48 | 430 | $child = $node->lastChild(); |
|
| 49 | 430 | while ($child !== null) { |
|
| 50 | 428 | if (! $this->blocksOnly || $child instanceof AbstractBlock) { |
|
| 51 | 428 | \array_push($stack, $child); |
|
| 52 | } |
||
| 53 | |||
| 54 | 428 | $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.