diff --git a/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php b/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php index 82664a4b75e..8d95667f56d 100644 --- a/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php +++ b/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php @@ -68,7 +68,8 @@ CODE_SAMPLE { $class = $node; $hasChanged = \false; - $this->traverseNodesWithCallable($node, function (Node $node) use($class, &$hasChanged) : ?PropertyFetch { + $isFinal = $class->isFinal(); + $this->traverseNodesWithCallable($node, function (Node $node) use($class, &$hasChanged, $isFinal) : ?PropertyFetch { if (!$node instanceof MethodCall) { return null; } @@ -86,6 +87,9 @@ CODE_SAMPLE if (!$classMethod instanceof ClassMethod) { return null; } + if (!$classMethod->isPrivate() && !$isFinal) { + return null; + } $propertyFetch = $this->matchLocalPropertyFetchInGetterMethod($classMethod); if (!$propertyFetch instanceof PropertyFetch) { return null; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index c0e1fc37872..6babe7b530b 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '5c8fa12ec90e4d4b55fd05f48509c538c243482d'; + public const PACKAGE_VERSION = 'aac9573e0ef040c236a569a9cbbe965af61ab0b8'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-02 05:03:12'; + public const RELEASE_DATE = '2023-12-02 15:56:28'; /** * @var int */