mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #9385 from ygottschalk/fix/9384-wrong-type-from-is-long
This commit is contained in:
commit
b7646d9706
@ -1871,9 +1871,9 @@ class AssertionFinder
|
||||
return new IsType(new Atomic\TString());
|
||||
case 'is_int':
|
||||
case 'is_integer':
|
||||
case 'is_long':
|
||||
return new IsType(new Atomic\TInt());
|
||||
case 'is_float':
|
||||
case 'is_long':
|
||||
case 'is_double':
|
||||
case 'is_real':
|
||||
return new IsType(new Atomic\TFloat());
|
||||
|
@ -1239,6 +1239,32 @@ class TypeTest extends TestCase
|
||||
strlen($s);
|
||||
}',
|
||||
],
|
||||
'testIsIntAndAliasesTypeNarrowing' => [
|
||||
'code' => '<?php
|
||||
/** @var mixed $a */
|
||||
$a;
|
||||
/** @var never $b */
|
||||
$b;
|
||||
/** @var never $c */
|
||||
$c;
|
||||
/** @var never $d */
|
||||
$d;
|
||||
if (is_int($a)) {
|
||||
$b = $a;
|
||||
}
|
||||
if (is_integer($a)) {
|
||||
$c = $a;
|
||||
}
|
||||
if (is_long($a)) {
|
||||
$d = $a;
|
||||
}
|
||||
',
|
||||
'assertions' => [
|
||||
'$b===' => 'int',
|
||||
'$c===' => 'int',
|
||||
'$d===' => 'int',
|
||||
],
|
||||
],
|
||||
'narrowWithCountToAllowNonTupleKeyedArray' => [
|
||||
'code' => '<?php
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user