Skip to content

Commit d1f2dcb

Browse files
fix
Co-Authored-By: Vincent Langlet <VincentLanglet@users.noreply.github.com>
1 parent 59a1dfc commit d1f2dcb

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/Analyser/TypeSpecifier.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,7 @@ private function getConditionalSpecifiedTypes(
15881588
(
15891589
$argumentExpr instanceof Node\Scalar
15901590
|| ($argumentExpr instanceof ConstFetch && in_array(strtolower($argumentExpr->name->toString()), ['true', 'false', 'null'], true))
1591-
&& ($ifType instanceof NeverType || $elseType instanceof NeverType)
1592-
)
1591+
) && ($ifType instanceof NeverType || $elseType instanceof NeverType)
15931592
) {
15941593
return null;
15951594
}

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ public function testImpossibleCheckTypeFunctionCall(): void
7474
'Call to function is_callable() with \'nonexistentFunction\' will always evaluate to false.',
7575
87,
7676
],
77+
[
78+
'Call to function is_numeric() with \'123\' will always evaluate to true.',
79+
102,
80+
],
81+
[
82+
'Call to function is_numeric() with \'blabla\' will always evaluate to false.',
83+
105,
84+
],
7785
[
7886
'Call to function is_numeric() with 123|float will always evaluate to true.',
7987
118,
@@ -223,11 +231,19 @@ public function testImpossibleCheckTypeFunctionCall(): void
223231
718,
224232
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
225233
],
234+
[
235+
'Call to function is_numeric() with \'123\' will always evaluate to true.',
236+
718,
237+
],
226238
[
227239
'Call to function assert() with false will always evaluate to false.',
228240
719,
229241
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
230242
],
243+
[
244+
'Call to function is_numeric() with \'blabla\' will always evaluate to false.',
245+
719,
246+
],
231247
[
232248
'Call to function assert() with true will always evaluate to true.',
233249
726,

0 commit comments

Comments
 (0)