@@ -261,7 +261,8 @@ public function hasInstanceProperty(string $propertyName): TrinaryLogic
261261 return TrinaryLogic::createMaybe ();
262262 }
263263
264- if ($ classReflection ->hasInstanceProperty ($ propertyName )) {
264+ $ classHasProperty = RecursionGuard::run ($ this , static fn (): bool => $ classReflection ->hasInstanceProperty ($ propertyName ));
265+ if ($ classHasProperty === true || $ classHasProperty instanceof ErrorType) {
265266 return TrinaryLogic::createYes ();
266267 }
267268
@@ -327,7 +328,17 @@ public function getUnresolvedInstancePropertyPrototype(string $propertyName, Cla
327328 throw new ClassNotFoundException ($ this ->className );
328329 }
329330
330- $ property = $ nakedClassReflection ->getInstanceProperty ($ propertyName , $ scope );
331+ $ property = RecursionGuard::run ($ this , static fn () => $ nakedClassReflection ->getInstanceProperty ($ propertyName , $ scope ));
332+ if ($ property instanceof ErrorType) {
333+ $ property = new DummyPropertyReflection ($ propertyName );
334+
335+ return new CallbackUnresolvedPropertyPrototypeReflection (
336+ $ property ,
337+ $ property ->getDeclaringClass (),
338+ false ,
339+ static fn (Type $ type ): Type => $ type ,
340+ );
341+ }
331342
332343 $ ancestor = $ this ->getAncestorWithClassName ($ property ->getDeclaringClass ()->getName ());
333344 $ resolvedClassReflection = null ;
@@ -356,7 +367,8 @@ public function hasStaticProperty(string $propertyName): TrinaryLogic
356367 return TrinaryLogic::createMaybe ();
357368 }
358369
359- if ($ classReflection ->hasStaticProperty ($ propertyName )) {
370+ $ classHasProperty = RecursionGuard::run ($ this , static fn (): bool => $ classReflection ->hasStaticProperty ($ propertyName ));
371+ if ($ classHasProperty === true || $ classHasProperty instanceof ErrorType) {
360372 return TrinaryLogic::createYes ();
361373 }
362374
@@ -398,7 +410,17 @@ public function getUnresolvedStaticPropertyPrototype(string $propertyName, Class
398410 throw new ClassNotFoundException ($ this ->className );
399411 }
400412
401- $ property = $ nakedClassReflection ->getStaticProperty ($ propertyName );
413+ $ property = RecursionGuard::run ($ this , static fn () => $ nakedClassReflection ->getStaticProperty ($ propertyName ));
414+ if ($ property instanceof ErrorType) {
415+ $ property = new DummyPropertyReflection ($ propertyName );
416+
417+ return new CallbackUnresolvedPropertyPrototypeReflection (
418+ $ property ,
419+ $ property ->getDeclaringClass (),
420+ false ,
421+ static fn (Type $ type ): Type => $ type ,
422+ );
423+ }
402424
403425 $ ancestor = $ this ->getAncestorWithClassName ($ property ->getDeclaringClass ()->getName ());
404426 $ resolvedClassReflection = null ;
0 commit comments