Skip to content

Commit ef1ccd2

Browse files
clxmstaabstaabm
authored andcommitted
fix
1 parent 26aef2d commit ef1ccd2

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/Analyser/TypeSpecifier.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ public function specifyTypesInCondition(
334334
&& strtolower((string) $exprNode->name) === 'get_parent_class'
335335
&& isset($exprNode->getArgs()[0])
336336
&& $constantType instanceof ConstantStringType
337-
&& $constantType->getValue() !== ''
337+
// the is_string() check should not be necessary, since ConstantStringType->getValue() returns 'string'
338+
&& is_string($constantType->getValue())
338339
) {
339340
$argType = $scope->getType($exprNode->getArgs()[0]->value);
340341
$objectType = new ObjectType($constantType->getValue());

‎tests/PHPStan/Analyser/data/bug-5552.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ public function happyPath($mixed, object $o, string $s): void
1111
if (get_parent_class($mixed) === A::class) {
1212
assertType('Bug5552\A|class-string<Bug5552\A>', $mixed);
1313
}
14+
assertType('mixed', $mixed);
15+
1416
if (A::class === get_parent_class($mixed)) {
1517
assertType('Bug5552\A|class-string<Bug5552\A>', $mixed);
1618
}
19+
assertType('mixed', $mixed);
20+
1721
if (get_parent_class($mixed) === 'Bug5552\A') {
1822
assertType('Bug5552\A|class-string<Bug5552\A>', $mixed);
1923
}
24+
assertType('mixed', $mixed);
25+
2026
if ('Bug5552\A' === get_parent_class($mixed)) {
2127
assertType('Bug5552\A|class-string<Bug5552\A>', $mixed);
2228
}

0 commit comments

Comments
 (0)