Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #9384 (Wrong type for variable checked with is_long) #9385

Merged
merged 1 commit into from Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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