Skip to content

Commit cd694f0

Browse files
committed
Merge branch 2.1.x into 2.2.x
2 parents 301cf48 + c24d365 commit cd694f0

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/PhpDoc/TypeNodeResolver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,9 @@ private function resolveIdentifierTypeNode(IdentifierTypeNode $typeNode, NameSco
504504
case 'parent':
505505
if ($this->getReflectionProvider()->hasClass($nameScope->getClassName())) {
506506
$classReflection = $this->getReflectionProvider()->getClass($nameScope->getClassName());
507-
if ($classReflection->getParentClass() !== null) {
508-
return new ObjectType($classReflection->getParentClass()->getName());
507+
$parentClass = $classReflection->getNativeReflection()->getParentClass();
508+
if ($parentClass !== false) {
509+
return new ObjectType($parentClass->getName());
509510
}
510511
}
511512

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,13 @@ public function testBug8835(): void
15221522
$this->assertNoErrors($errors);
15231523
}
15241524

1525+
public function testBug14439(): void
1526+
{
1527+
// endless loop crash with @extends parent<T>
1528+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-14439.php');
1529+
$this->assertNoErrors($errors);
1530+
}
1531+
15251532
/**
15261533
* @param string[]|null $allAnalysedFiles
15271534
* @return list<Error>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug14439;
4+
5+
/**
6+
* @template T
7+
*/
8+
abstract class AbstractBar
9+
{
10+
}
11+
12+
/**
13+
* @template T
14+
* @extends parent<T>
15+
*/
16+
abstract class AbstractFoo extends AbstractBar
17+
{
18+
}
19+
20+
/**
21+
* @template T of int
22+
* @extends parent<T>
23+
*/
24+
class Foo extends AbstractFoo
25+
{
26+
}

0 commit comments

Comments
 (0)