Skip to content

Commit

Permalink
[NodeTraverser] Use NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN…
Browse files Browse the repository at this point in the history
… instead of NodeTraverser::DONT_TRAVERSE__CHILDREN (#3233)
  • Loading branch information
samsonasik committed Dec 21, 2022
1 parent f132077 commit 432d3e4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function enterNode(Node $node): ?int
if (count($nestedChainMethodCalls) > $this->nestedChainMethodCallLimit) {
$this->removingExpression = $node;

return NodeTraverser::DONT_TRAVERSE_CHILDREN;
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
}

Expand Down
2 changes: 1 addition & 1 deletion rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function resolveFetchedPropertiesToTypesFromClass(Class_ $class): array
// skip anonymous class scope
$isAnonymousClass = $this->classAnalyzer->isAnonymousClass($node);
if ($isAnonymousClass) {
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

if (! $node instanceof PropertyFetch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private function refactorThrow(Throw_ $throw, Variable $catchedThrowableVariable
$new->setAttribute(AttributeKey::ORIGINAL_NODE, null);

// nothing more to add
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

private function resolveExceptionArgumentPosition(Name $exceptionName): ?int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private function resolveAssignedTypeInStmtsByPropertyName(array $stmts, string $

$this->traverseNodesWithCallable($stmts, function (Node $node) use ($propertyName, &$resolvedTypes): ?int {
if ($node instanceof ClassMethod && $this->isName($node, MethodName::CONSTRUCT)) {
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

if (! $this->isPropertyFetchAssignOfPropertyName($node, $propertyName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ private function findCurrentScopeYieldNodes(FunctionLike $functionLike): array
) use (&$yieldNodes): ?int {
// skip anonymous class and inner function
if ($node instanceof Class_) {
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

// skip nested scope
if ($node instanceof FunctionLike) {
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

if ($node instanceof Stmt && ! $node instanceof Expression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function collectReturns(FunctionLike $functionLike): array
) use (&$returns): ?int {
// skip Return_ nodes in nested functions or switch statements
if ($node instanceof FunctionLike) {
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

if (! $node instanceof Return_) {
Expand Down

0 comments on commit 432d3e4

Please sign in to comment.