@@ -95,10 +95,6 @@ public function getNodeTypes(): array
9595 */
9696 public function refactor (Node $ node ): ?Node
9797 {
98- if (! $ node instanceof ClassMethod) {
99- return null ;
100- }
101-
10298 $ returnType = $ node ->returnType ;
10399
104100 if (! $ returnType instanceof Identifier && ! $ returnType instanceof FullyQualified) {
@@ -156,7 +152,7 @@ private function isDeclaredTypeFinal(string $declaredType): bool
156152 $ declaredObjectType = new ObjectType ($ declaredType );
157153 $ classReflection = $ declaredObjectType ->getClassReflection ();
158154
159- if ($ classReflection === null ) {
155+ if (! $ classReflection instanceof ClassReflection ) {
160156 return false ;
161157 }
162158
@@ -168,7 +164,7 @@ private function isActualTypeAnonymous(string $actualType): bool
168164 $ actualObjectType = new ObjectType ($ actualType );
169165 $ classReflection = $ actualObjectType ->getClassReflection ();
170166
171- if ($ classReflection === null ) {
167+ if (! $ classReflection instanceof ClassReflection ) {
172168 return false ;
173169 }
174170
@@ -218,13 +214,13 @@ private function hasParentMethodWithNonObjectReturn(ClassMethod $classMethod): b
218214
219215 $ parentClassMethod = $ this ->astResolver ->resolveClassMethod ($ ancestor ->getName (), $ methodName );
220216
221- if ($ parentClassMethod === null ) {
217+ if (! $ parentClassMethod instanceof ClassMethod ) {
222218 continue ;
223219 }
224220
225221 $ parentReturnType = $ parentClassMethod ->returnType ;
226222
227- if ($ parentReturnType === null ) {
223+ if (! $ parentReturnType instanceof Node ) {
228224 continue ;
229225 }
230226
@@ -238,9 +234,9 @@ private function hasParentMethodWithNonObjectReturn(ClassMethod $classMethod): b
238234 return false ;
239235 }
240236
241- private function getActualReturnClass (ClassMethod $ node ): ?string
237+ private function getActualReturnClass (ClassMethod $ classMethod ): ?string
242238 {
243- $ returnStatements = $ this ->betterNodeFinder ->findReturnsScoped ($ node );
239+ $ returnStatements = $ this ->betterNodeFinder ->findReturnsScoped ($ classMethod );
244240
245241 if ($ returnStatements === []) {
246242 return null ;
0 commit comments