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

[Scope] Fix resolve Scope from fluent call #5743

Merged
merged 8 commits into from
Mar 26, 2024
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
9 changes: 3 additions & 6 deletions src/Console/Command/CustomRuleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private function setupRectorTestSuite(string $currentDirectory): void
return;
}

$phpunitXML = $this->updatePHPUnitXMLFile($domDocument, $testsuitesElement, $phpunitFilePath);
$phpunitXML = $this->updatePHPUnitXMLFile($domDocument, $testsuitesElement);

FileSystem::write($phpunitFilePath, $phpunitXML, null);

Expand Down Expand Up @@ -219,11 +219,8 @@ private function hasRectorTestSuite(DOMDocument $domDocument): bool
return false;
}

private function updatePHPUnitXMLFile(
DOMDocument $domDocument,
DOMElement $testsuitesElement,
string $phpunitFilePath
): string {
private function updatePHPUnitXMLFile(DOMDocument $domDocument, DOMElement $testsuitesElement): string
{
$domElement = $domDocument->createElement('testsuite');
$domElement->setAttribute('name', 'rector');

Expand Down
10 changes: 8 additions & 2 deletions src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public function enterNode(Node $node): ?Node
return null;
}

if ($node->getAttribute(AttributeKey::EXPRESSION_DEPTH) < 2
&& $node->getAttribute(AttributeKey::IS_ARG_VALUE) !== true) {
if ($this->shouldSkipExpr($node)) {
return null;
}

Expand All @@ -79,4 +78,11 @@ public function enterNode(Node $node): ?Node

return null;
}

private function shouldSkipExpr(Expr $expr): bool
{
return $expr->getAttribute(AttributeKey::EXPRESSION_DEPTH) < 2
&& $expr->getAttribute(AttributeKey::IS_ARG_VALUE) !== true
&& $expr->getAttribute(AttributeKey::IS_PARAM_VAR) === true;
}
}