24
24
use PHPStan \Reflection \ClassMemberAccessAnswerer ;
25
25
use PHPStan \Reflection \ClassReflection ;
26
26
use PHPStan \Reflection \ConstantReflection ;
27
+ use PHPStan \Reflection \Dummy \DummyPropertyReflection ;
27
28
use PHPStan \Reflection \ExtendedMethodReflection ;
28
29
use PHPStan \Reflection \Php \UniversalObjectCratesClassReflectionExtension ;
29
30
use PHPStan \Reflection \PropertyReflection ;
30
31
use PHPStan \Reflection \ReflectionProviderStaticAccessor ;
31
32
use PHPStan \Reflection \TrivialParametersAcceptor ;
33
+ use PHPStan \Reflection \Type \CallbackUnresolvedPropertyPrototypeReflection ;
32
34
use PHPStan \Reflection \Type \CalledOnTypeUnresolvedMethodPrototypeReflection ;
33
35
use PHPStan \Reflection \Type \CalledOnTypeUnresolvedPropertyPrototypeReflection ;
34
36
use PHPStan \Reflection \Type \UnionTypeUnresolvedPropertyPrototypeReflection ;
@@ -159,7 +161,8 @@ public function hasProperty(string $propertyName): TrinaryLogic
159
161
return TrinaryLogic::createMaybe ();
160
162
}
161
163
162
- if ($ classReflection ->hasProperty ($ propertyName )) {
164
+ $ classHasProperty = RecursionGuard::run ($ this , static fn (): bool => $ classReflection ->hasProperty ($ propertyName ));
165
+ if ($ classHasProperty === true || $ classHasProperty instanceof ErrorType) {
163
166
return TrinaryLogic::createYes ();
164
167
}
165
168
@@ -225,7 +228,17 @@ public function getUnresolvedPropertyPrototype(string $propertyName, ClassMember
225
228
throw new ClassNotFoundException ($ this ->className );
226
229
}
227
230
228
- $ property = $ nakedClassReflection ->getProperty ($ propertyName , $ scope );
231
+ $ property = RecursionGuard::run ($ this , static fn () => $ nakedClassReflection ->getProperty ($ propertyName , $ scope ));
232
+ if ($ property instanceof ErrorType) {
233
+ $ property = new DummyPropertyReflection ();
234
+
235
+ return new CallbackUnresolvedPropertyPrototypeReflection (
236
+ $ property ,
237
+ $ property ->getDeclaringClass (),
238
+ false ,
239
+ static fn (Type $ type ): Type => $ type ,
240
+ );
241
+ }
229
242
230
243
$ ancestor = $ this ->getAncestorWithClassName ($ property ->getDeclaringClass ()->getName ());
231
244
$ resolvedClassReflection = null ;
@@ -247,6 +260,9 @@ public function getUnresolvedPropertyPrototype(string $propertyName, ClassMember
247
260
);
248
261
}
249
262
263
+ /**
264
+ * @deprecated Not in use anymore.
265
+ */
250
266
public function getPropertyWithoutTransformingStatic (string $ propertyName , ClassMemberAccessAnswerer $ scope ): PropertyReflection
251
267
{
252
268
$ classReflection = $ this ->getNakedClassReflection ();
0 commit comments