diff --git a/compiler/build/scoper.inc.php b/compiler/build/scoper.inc.php index de2efea971a0..050efd807136 100644 --- a/compiler/build/scoper.inc.php +++ b/compiler/build/scoper.inc.php @@ -168,5 +168,7 @@ function (string $filePath, string $prefix, string $content): string { 'PhpParser\*', // mimics https://github.com/phpstan/phpstan-src/commit/23d5ca04ab6213f53a0e6c2e77857b23a73aa41d 'Hoa\*', + // @see https://github.com/rectorphp/rector/issues/2955 + 'OxidEsales\*', ], ]; diff --git a/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php b/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php index f6f14a4a4997..34c18fa05f35 100644 --- a/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php +++ b/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php @@ -11,6 +11,7 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\FunctionLike; +use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\Core\RectorDefinition\CodeSample; use Rector\Core\RectorDefinition\RectorDefinition; @@ -111,6 +112,10 @@ private function shouldSkip(Node $node): bool return false; } + if (! $node->name instanceof Name) { + return true; + } + $functionName = $this->getName($node->name); if ($functionName === null) { return false; diff --git a/rules/phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php b/rules/phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php index fb646d27df94..6e223cc9a324 100644 --- a/rules/phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php +++ b/rules/phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php @@ -107,8 +107,11 @@ private function shouldSkipClass(Class_ $class, string $testCaseClassName): bool return true; } - /** @var PhpDocInfo $phpDocInfo */ + /** @var PhpDocInfo|null $phpDocInfo */ $phpDocInfo = $class->getAttribute(AttributeKey::PHP_DOC_INFO); + if ($phpDocInfo === null) { + return true; + } $seeTags = $phpDocInfo->getTagsByName('see'); diff --git a/rules/phpunit/src/Rector/SpecificMethod/AssertTrueFalseInternalTypeToSpecificMethodRector.php b/rules/phpunit/src/Rector/SpecificMethod/AssertTrueFalseInternalTypeToSpecificMethodRector.php index 668dcc1c4e5d..f1e386057915 100644 --- a/rules/phpunit/src/Rector/SpecificMethod/AssertTrueFalseInternalTypeToSpecificMethodRector.php +++ b/rules/phpunit/src/Rector/SpecificMethod/AssertTrueFalseInternalTypeToSpecificMethodRector.php @@ -92,9 +92,13 @@ public function refactor(Node $node): ?Node return null; } - /** @var FuncCall $firstArgumentValue */ + /** @var FuncCall|Node $firstArgumentValue */ $firstArgumentValue = $node->args[0]->value; + if (! $firstArgumentValue instanceof FuncCall) { + return null; + } + $functionName = $this->getName($firstArgumentValue); if (! isset(self::OLD_FUNCTIONS_TO_TYPES[$functionName])) { return null;