From 7b685c5e87ea1178bb1a8977f41242a104c6e305 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 10 Sep 2025 19:03:11 +0700 Subject: [PATCH] Fix PHPStan notice on PHPStan 2.1.23 --- .../Rector/MethodCall/SpecificAssertContainsRector.php | 4 ++++ .../SpecificAssertContainsWithoutIdentityRector.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/rules/PHPUnit80/Rector/MethodCall/SpecificAssertContainsRector.php b/rules/PHPUnit80/Rector/MethodCall/SpecificAssertContainsRector.php index 57b276b8..6a8bf9ca 100644 --- a/rules/PHPUnit80/Rector/MethodCall/SpecificAssertContainsRector.php +++ b/rules/PHPUnit80/Rector/MethodCall/SpecificAssertContainsRector.php @@ -94,6 +94,10 @@ public function refactor(Node $node): ?Node } $methodName = $this->getName($node->name); + if ($methodName === null) { + return null; + } + $newMethodName = self::OLD_TO_NEW_METHOD_NAMES[$methodName]; $node->name = new Identifier($newMethodName); diff --git a/rules/PHPUnit90/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php b/rules/PHPUnit90/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php index 66a220cc..1ea76c92 100644 --- a/rules/PHPUnit90/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php +++ b/rules/PHPUnit90/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php @@ -117,6 +117,10 @@ public function refactor(Node $node): ?Node /* here we search for element of array without identity check and we can replace functions */ $methodName = $this->getName($node->name); + if ($methodName === null) { + return null; + } + $node->name = new Identifier(self::OLD_METHODS_NAMES_TO_NEW_NAMES['string'][$methodName]); unset($node->args[3], $node->args[4]);