Skip to content

Commit 6ccb24e

Browse files
clxmstaabstaabm
authored andcommitted
add more assertions
1 parent ef1ccd2 commit 6ccb24e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎src/Analyser/TypeSpecifier.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public function specifyTypesInCondition(
328328
}
329329

330330
if (
331-
!$context->null()
331+
$context->true()
332332
&& $exprNode instanceof FuncCall
333333
&& $exprNode->name instanceof Name
334334
&& strtolower((string) $exprNode->name) === 'get_parent_class'

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,29 @@ public function happyPath($mixed, object $o, string $s): void
1010
{
1111
if (get_parent_class($mixed) === A::class) {
1212
assertType('Bug5552\A|class-string<Bug5552\A>', $mixed);
13+
} else {
14+
assertType('mixed', $mixed);
1315
}
1416
assertType('mixed', $mixed);
1517

1618
if (A::class === get_parent_class($mixed)) {
1719
assertType('Bug5552\A|class-string<Bug5552\A>', $mixed);
20+
} else {
21+
assertType('mixed', $mixed);
1822
}
1923
assertType('mixed', $mixed);
2024

2125
if (get_parent_class($mixed) === 'Bug5552\A') {
2226
assertType('Bug5552\A|class-string<Bug5552\A>', $mixed);
27+
} else {
28+
assertType('mixed', $mixed);
2329
}
2430
assertType('mixed', $mixed);
2531

2632
if ('Bug5552\A' === get_parent_class($mixed)) {
2733
assertType('Bug5552\A|class-string<Bug5552\A>', $mixed);
34+
} else {
35+
assertType('mixed', $mixed);
2836
}
2937
assertType('mixed', $mixed);
3038

0 commit comments

Comments
 (0)