@@ -17,14 +17,14 @@ class Seeker implements SeekerInterface
1717 * Attempts to find all children that match the rule
1818 * given.
1919 *
20+ * @var InnerNode[] $nodes
2021 * @throws ChildNotFoundException
2122 */
2223 public function seek (array $ nodes , RuleDTO $ rule , array $ options , bool $ depthFirst ): array
2324 {
2425 // XPath index
2526 if ($ rule ->getTag () !== null && \is_numeric ($ rule ->getKey ())) {
2627 $ count = 0 ;
27- /** @var AbstractNode $node */
2828 foreach ($ nodes as $ node ) {
2929 if ($ rule ->getTag () == '* '
3030 || $ rule ->getTag () == $ node ->getTag ()
@@ -44,7 +44,6 @@ public function seek(array $nodes, RuleDTO $rule, array $options, bool $depthFir
4444 $ options = $ this ->flattenOptions ($ options );
4545
4646 $ return = [];
47- /** @var InnerNode $node */
4847 foreach ($ nodes as $ node ) {
4948 // check if we are a leaf
5049 if ($ node instanceof LeafNode || !$ node ->hasChildren ()
@@ -77,24 +76,23 @@ public function seek(array $nodes, RuleDTO $rule, array $options, bool $depthFir
7776 if ($ pass ) {
7877 // it passed all checks
7978 $ return [] = $ child ;
80- } else {
81- // this child failed to be matched
82- if ($ child instanceof InnerNode && $ child ->hasChildren ()
83- ) {
84- if ($ depthFirst ) {
85- if (!isset ($ options ['checkGrandChildren ' ])
86- || $ options ['checkGrandChildren ' ]
87- ) {
88- // we have a child that failed but are not leaves.
89- $ matches = $ this ->seek ([$ child ], $ rule , $ options , $ depthFirst );
90- foreach ($ matches as $ match ) {
91- $ return [] = $ match ;
92- }
79+ }
80+ // this child failed to be matched
81+ if ($ child instanceof InnerNode && $ child ->hasChildren ()
82+ ) {
83+ if ($ depthFirst ) {
84+ if (!isset ($ options ['checkGrandChildren ' ])
85+ || $ options ['checkGrandChildren ' ]
86+ ) {
87+ // we have a child that failed but are not leaves.
88+ $ matches = $ this ->seek ([$ child ], $ rule , $ options , $ depthFirst );
89+ foreach ($ matches as $ match ) {
90+ $ return [] = $ match ;
9391 }
94- } else {
95- // we still want to check its children
96- $ children [] = $ child ;
9792 }
93+ } else {
94+ // we still want to check its children
95+ $ children [] = $ child ;
9896 }
9997 }
10098
0 commit comments