File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 1919use PHPStan \Type \IntersectionType ;
2020use PHPStan \Type \IsSuperTypeOfResult ;
2121use PHPStan \Type \ObjectType ;
22+ use PHPStan \Type \RecursionGuard ;
2223use PHPStan \Type \Type ;
2324use PHPStan \Type \TypeWithClassName ;
2425use PHPStan \Type \UnionType ;
@@ -95,7 +96,11 @@ public function getReferencedClasses(): array
9596 {
9697 $ classes = parent ::getReferencedClasses ();
9798 foreach ($ this ->types as $ type ) {
98- foreach ($ type ->getReferencedClasses () as $ referencedClass ) {
99+ $ referencedClasses = RecursionGuard::runOnObjectIdentity ($ type , static fn () => $ type ->getReferencedClasses ());
100+ if ($ referencedClasses instanceof ErrorType) {
101+ continue ;
102+ }
103+ foreach ($ referencedClasses as $ referencedClass ) {
99104 $ classes [] = $ referencedClass ;
100105 }
101106 }
Original file line number Diff line number Diff line change @@ -1499,6 +1499,13 @@ public function testBug14324(): void
14991499 $ this ->assertNoErrors ($ errors );
15001500 }
15011501
1502+ public function testBug13801 (): void
1503+ {
1504+ // endless loop crash
1505+ $ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-13801.php ' );
1506+ $ this ->assertNoErrors ($ errors );
1507+ }
1508+
15021509 /**
15031510 * @param string[]|null $allAnalysedFiles
15041511 * @return list<Error>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Bug13801 ;
6+
7+ /**
8+ * @template TValue of object
9+ */
10+ interface Cast
11+ {
12+ }
13+
14+ /**
15+ * @template TCast of Cast<static>
16+ */
17+ interface Castable
18+ {
19+ }
You can’t perform that action at this time.
0 commit comments