@@ -103,11 +103,11 @@ public function refactor(Node $node): ?Node
103103
104104 $ classReflection = $ this ->reflectionProvider ->getClass ($ className );
105105
106- if (! $ classReflection ->is (Model::class)) {
107- continue ;
106+ if ($ classReflection ->is (Model::class)) {
107+ break ;
108108 }
109109
110- break ;
110+ $ classReflection = null ;
111111 }
112112
113113 if (! $ classReflection instanceof ClassReflection) {
@@ -135,9 +135,9 @@ public function configure(array $configuration): void
135135
136136 private function isMagicMethod (ClassReflection $ classReflection , string $ methodName ): bool
137137 {
138- if (! $ classReflection ->hasMethod ($ methodName )) {
138+ if (! $ classReflection ->hasNativeMethod ($ methodName )) {
139139 // if the class doesn't have the method then check if the method is a scope
140- if ($ classReflection ->hasMethod ('scope ' . ucfirst ($ methodName ))) {
140+ if ($ classReflection ->hasNativeMethod ('scope ' . ucfirst ($ methodName ))) {
141141 return true ;
142142 }
143143
@@ -146,6 +146,10 @@ private function isMagicMethod(ClassReflection $classReflection, string $methodN
146146 || $ this ->isPublicMethod (QueryBuilder::class, $ methodName );
147147 }
148148
149+ if (! $ classReflection ->hasMethod ($ methodName )) {
150+ return false ; // no mixin
151+ }
152+
149153 $ extendedMethodReflection = $ classReflection ->getMethod ($ methodName , new OutOfClassScope );
150154
151155 if (! $ extendedMethodReflection ->isPublic () || $ extendedMethodReflection ->isStatic ()) {
@@ -166,11 +170,11 @@ private function isPublicMethod(string $className, string $methodName): bool
166170
167171 $ classReflection = $ this ->reflectionProvider ->getClass ($ className );
168172
169- if (! $ classReflection ->hasMethod ($ methodName )) {
173+ if (! $ classReflection ->hasNativeMethod ($ methodName )) {
170174 return false ;
171175 }
172176
173- $ extendedMethodReflection = $ classReflection ->getMethod ($ methodName, new OutOfClassScope );
177+ $ extendedMethodReflection = $ classReflection ->getNativeMethod ($ methodName );
174178
175179 return $ extendedMethodReflection ->isPublic () && ! $ extendedMethodReflection ->isStatic ();
176180 }
0 commit comments