Skip to content

Commit 67f32b1

Browse files
Fix
1 parent 04989d6 commit 67f32b1

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/Type/ObjectType.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ public function hasInstanceProperty(string $propertyName): TrinaryLogic
258258
return TrinaryLogic::createMaybe();
259259
}
260260

261-
if ($classReflection->hasInstanceProperty($propertyName)) {
261+
$classHasProperty = RecursionGuard::run($this, static fn (): bool => $classReflection->hasInstanceProperty($propertyName));
262+
if ($classHasProperty === true || $classHasProperty instanceof ErrorType) {
262263
return TrinaryLogic::createYes();
263264
}
264265

@@ -324,7 +325,17 @@ public function getUnresolvedInstancePropertyPrototype(string $propertyName, Cla
324325
throw new ClassNotFoundException($this->className);
325326
}
326327

327-
$property = $nakedClassReflection->getInstanceProperty($propertyName, $scope);
328+
$property = RecursionGuard::run($this, static fn () => $nakedClassReflection->getInstanceProperty($propertyName, $scope));
329+
if ($property instanceof ErrorType) {
330+
$property = new DummyPropertyReflection($propertyName);
331+
332+
return new CallbackUnresolvedPropertyPrototypeReflection(
333+
$property,
334+
$property->getDeclaringClass(),
335+
false,
336+
static fn (Type $type): Type => $type,
337+
);
338+
}
328339

329340
$ancestor = $this->getAncestorWithClassName($property->getDeclaringClass()->getName());
330341
$resolvedClassReflection = null;
@@ -353,7 +364,8 @@ public function hasStaticProperty(string $propertyName): TrinaryLogic
353364
return TrinaryLogic::createMaybe();
354365
}
355366

356-
if ($classReflection->hasStaticProperty($propertyName)) {
367+
$classHasProperty = RecursionGuard::run($this, static fn (): bool => $classReflection->hasStaticProperty($propertyName));
368+
if ($classHasProperty === true || $classHasProperty instanceof ErrorType) {
357369
return TrinaryLogic::createYes();
358370
}
359371

@@ -395,7 +407,17 @@ public function getUnresolvedStaticPropertyPrototype(string $propertyName, Class
395407
throw new ClassNotFoundException($this->className);
396408
}
397409

398-
$property = $nakedClassReflection->getStaticProperty($propertyName);
410+
$property = RecursionGuard::run($this, static fn () => $nakedClassReflection->getStaticProperty($propertyName, $scope));
411+
if ($property instanceof ErrorType) {
412+
$property = new DummyPropertyReflection($propertyName);
413+
414+
return new CallbackUnresolvedPropertyPrototypeReflection(
415+
$property,
416+
$property->getDeclaringClass(),
417+
false,
418+
static fn (Type $type): Type => $type,
419+
);
420+
}
399421

400422
$ancestor = $this->getAncestorWithClassName($property->getDeclaringClass()->getName());
401423
$resolvedClassReflection = null;

0 commit comments

Comments
 (0)