@@ -31,6 +31,7 @@ final class PrivatizeFinalClassMethodRector extends AbstractRector
3131 * @see https://regex101.com/r/Dx0WN5/2
3232 */
3333 private const LARAVEL_MODEL_ATTRIBUTE_REGEX = '/^[gs]et.+Attribute$/ ' ;
34+
3435 /**
3536 * @var string
3637 * @see https://regex101.com/r/hxOGeN/2
@@ -104,7 +105,7 @@ public function refactor(Node $node): ?Node
104105 $ hasChanged = false ;
105106
106107 foreach ($ node ->getMethods () as $ classMethod ) {
107- if ($ this ->shouldSkipClassMethod ($ classMethod )) {
108+ if ($ this ->shouldSkipClassMethod ($ classReflection , $ classMethod )) {
108109 continue ;
109110 }
110111
@@ -133,7 +134,7 @@ public function refactor(Node $node): ?Node
133134 return null ;
134135 }
135136
136- private function shouldSkipClassMethod (ClassMethod $ classMethod ): bool
137+ private function shouldSkipClassMethod (ClassReflection $ classReflection , ClassMethod $ classMethod ): bool
137138 {
138139 // edge case in nette framework
139140 /** @var string $methodName */
@@ -150,7 +151,7 @@ private function shouldSkipClassMethod(ClassMethod $classMethod): bool
150151 return true ;
151152 }
152153
153- if ($ this ->shouldSkipClassMethodLaravel ($ classMethod )) {
154+ if ($ this ->shouldSkipClassMethodLaravel ($ classReflection , $ classMethod )) {
154155 return true ;
155156 }
156157
@@ -169,14 +170,8 @@ function (Node $node): bool {
169170 return $ hasParentCall ;
170171 }
171172
172- private function shouldSkipClassMethodLaravel (ClassMethod $ classMethod ): bool
173+ private function shouldSkipClassMethodLaravel (ClassReflection $ classReflection , ClassMethod $ classMethod ): bool
173174 {
174- $ classReflection = ScopeFetcher::fetch ($ classMethod )->getClassReflection ();
175-
176- if (! $ classReflection instanceof ClassReflection) {
177- return false ;
178- }
179-
180175 if (! $ classReflection ->is ('Illuminate\Database\Eloquent\Model ' )) {
181176 return false ;
182177 }
0 commit comments