diff --git a/rules-tests/Naming/Rector/ClassMethod/RenameParamToMatchTypeRector/Fixture/skip_rewindable_generator.php.inc b/rules-tests/Naming/Rector/ClassMethod/RenameParamToMatchTypeRector/Fixture/skip_rewindable_generator.php.inc new file mode 100644 index 00000000000..5c357d01556 --- /dev/null +++ b/rules-tests/Naming/Rector/ClassMethod/RenameParamToMatchTypeRector/Fixture/skip_rewindable_generator.php.inc @@ -0,0 +1,12 @@ +isGenerator($param)) { + return true; + } + if ($this->isDateTimeAtNamingConvention($param)) { return true; } @@ -222,17 +226,11 @@ private function isUsedInIfAndOtherBranches(Variable $variable, string $currentV return false; } - /** - * @TODO Remove once ParamRenamer created - */ private function isRamseyUuidInterface(Param $param): bool { return $this->nodeTypeResolver->isObjectType($param, new ObjectType('Ramsey\Uuid\UuidInterface')); } - /** - * @TODO Remove once ParamRenamer created - */ private function isDateTimeAtNamingConvention(Param $param): bool { $type = $this->nodeTypeResolver->getType($param); @@ -249,4 +247,12 @@ private function isDateTimeAtNamingConvention(Param $param): bool $currentName = $this->nodeNameResolver->getName($param); return StringUtils::isMatch($currentName, self::AT_NAMING_REGEX . ''); } + + private function isGenerator(Param $param): bool + { + return $this->nodeTypeResolver->isObjectType( + $param, + new ObjectType('Symfony\Component\DependencyInjection\Argument\RewindableGenerator') + ); + } } diff --git a/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php b/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php index 5aa7e83f2bb..8c06e9d7e1f 100644 --- a/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php +++ b/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php @@ -103,9 +103,13 @@ public function refactor(Node $node): ?Node return null; } - $hasChanged = true; + $propertyFetch = $this->matchLocalPropertyFetchInGetterMethod($classMethod); + if (! $propertyFetch instanceof PropertyFetch) { + return null; + } - return $this->matchLocalPropertyFetchInGetterMethod($classMethod); + $hasChanged = true; + return $propertyFetch; }); if ($hasChanged) {