1 | <?php |
||
17 | final class NodeWalker |
||
18 | { |
||
19 | /** |
||
20 | * @var Node |
||
21 | */ |
||
22 | private $root; |
||
23 | |||
24 | /** |
||
25 | * @var Node|null |
||
26 | */ |
||
27 | private $current; |
||
28 | |||
29 | /** |
||
30 | * @var bool |
||
31 | */ |
||
32 | private $entering; |
||
33 | |||
34 | /** |
||
35 | * @param Node $root |
||
36 | */ |
||
37 | 2469 | public function __construct(Node $root) |
|
43 | |||
44 | /** |
||
45 | * Returns an event which contains node and entering flag |
||
46 | * (entering is true when we enter a Node from a parent or sibling, |
||
47 | * and false when we reenter it from child) |
||
48 | * |
||
49 | * @return NodeWalkerEvent|null |
||
50 | */ |
||
51 | 2469 | public function next(): ?NodeWalkerEvent |
|
78 | |||
79 | /** |
||
80 | * Resets the iterator to resume at the specified node |
||
81 | * |
||
82 | * @param Node $node |
||
83 | * @param bool $entering |
||
84 | */ |
||
85 | 3 | public function resumeAt(Node $node, bool $entering = true) |
|
90 | } |
||
91 |