Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NodeTraverser] Use NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN instead of NodeTraverser::DONT_TRAVERSE__CHILDREN #3233

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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