-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
use PHPStan\Reflection\Php\PhpClassReflectionExtension; | ||
use PHPStan\Reflection\Php\PhpPropertyReflection; | ||
use PHPStan\ShouldNotHappenException; | ||
use PHPStan\Type\CircularClassReflectionResolutionException; | ||
use PHPStan\Type\CircularTypeAliasDefinitionException; | ||
use PHPStan\Type\Constant\ConstantIntegerType; | ||
use PHPStan\Type\ErrorType; | ||
|
@@ -193,7 +194,11 @@ public function getParentClass(): ?ClassReflection | |
return $this->cachedParentClass = null; | ||
} | ||
|
||
$extendsTag = $this->getFirstExtendsTag(); | ||
try { | ||
$extendsTag = $this->getFirstExtendsTag(); | ||
} catch (CircularClassReflectionResolutionException) { | ||
return $this->reflectionProvider->getClass($parentClass->getName()); | ||
} | ||
|
||
if ($extendsTag !== null && $this->isValidAncestorType($extendsTag->getType(), [$parentClass->getName()])) { | ||
$extendedType = $extendsTag->getType(); | ||
|
@@ -1349,16 +1354,17 @@ private function getFirstExtendsTag(): ?ExtendsTag | |
/** @return array<string, ExtendsTag> */ | ||
public function getExtendsTags(): array | ||
Check failure on line 1355 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan (7.4, ubuntu-latest)
|
||
{ | ||
if (isset(self::$resolvingExtendsTag[$this->getName()])) { | ||
return []; | ||
} | ||
self::$resolvingExtendsTag[$this->getName()] = true; | ||
|
||
$resolvedPhpDoc = $this->getResolvedPhpDoc(); | ||
if ($resolvedPhpDoc === null) { | ||
return []; | ||
} | ||
|
||
// prevent circular reference | ||
if (isset(self::$resolvingExtendsTag[$this->getName()])) { | ||
throw new CircularClassReflectionResolutionException(); | ||
Check failure on line 1364 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan with result cache (8.2)
Check failure on line 1364 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan with result cache (8.1)
Check failure on line 1364 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan (8.2, ubuntu-latest)
Check failure on line 1364 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan (8.1, ubuntu-latest)
Check failure on line 1364 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan (8.0, ubuntu-latest)
Check failure on line 1364 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan (8.2, windows-latest)
Check failure on line 1364 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan (8.0, windows-latest)
Check failure on line 1364 in src/Reflection/ClassReflection.php GitHub Actions / PHPStan (8.1, windows-latest)
|
||
} | ||
self::$resolvingExtendsTag[$this->getName()] = true; | ||
|
||
$extendTags = $resolvedPhpDoc->getExtendsTags(); | ||
|
||
unset(self::$resolvingExtendsTag[$this->getName()]); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Type; | ||
|
||
use Exception; | ||
|
||
class CircularClassReflectionResolutionException extends Exception | ||
{ | ||
|
||
} |