1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
This commit is contained in:
Yannick Gottschalk 2023-02-23 17:23:46 +01:00
parent e96a929451
commit f026226aa3
2 changed files with 27 additions and 1 deletions

View File

@ -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());

View File

@ -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
/**