Skip to content

Commit

Permalink
Merge pull request #9385 from ygottschalk/fix/9384-wrong-type-from-is…
Browse files Browse the repository at this point in the history
…-long
  • Loading branch information
weirdan committed Feb 23, 2023
2 parents e96a929 + f026226 commit b7646d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Expand Up @@ -1871,9 +1871,9 @@ private static function getIsAssertion(string $function_name): ?Assertion
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());
Expand Down
26 changes: 26 additions & 0 deletions tests/TypeReconciliation/TypeTest.php
Expand Up @@ -1239,6 +1239,32 @@ function foo(array $arr) : void {
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
/**
Expand Down

0 comments on commit b7646d9

Please sign in to comment.