diff --git a/src/Console/Command/CustomRuleCommand.php b/src/Console/Command/CustomRuleCommand.php index f22d5994b4d..0d91b1c6450 100644 --- a/src/Console/Command/CustomRuleCommand.php +++ b/src/Console/Command/CustomRuleCommand.php @@ -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); @@ -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'); diff --git a/src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php b/src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php index d84713701fc..2d828eadcf5 100644 --- a/src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php +++ b/src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php @@ -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; } @@ -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; + } }