Skip to content

Commit b46cca1

Browse files
Fix
1 parent 5d6f582 commit b46cca1

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

tests/PHPStan/Analyser/nsrt/bug-14397-pre-php85.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/PHPStan/Analyser/nsrt/bug-14397.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,26 @@
44

55
namespace Bug14397;
66

7+
use PHPStan\TrinaryLogic;
8+
79
use function filter_var;
810
use function PHPStan\Testing\assertType;
11+
use function PHPStan\Testing\assertVariableCertainty;
912

1013
function test(string $ipAddress): void
1114
{
1215
assertType('non-falsy-string|false', filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_GLOBAL_RANGE));
1316
}
17+
18+
function test2(mixed $mixed): void
19+
{
20+
try {
21+
filter_var($mixed, FILTER_VALIDATE_INT, FILTER_FLAG_GLOBAL_RANGE);
22+
$foo = 1;
23+
} catch (\Filter\FilterFailedException $e) {
24+
assertVariableCertainty(TrinaryLogic::createYes(), $foo);
25+
}
26+
27+
assertType('int|false', filter_var($mixed, FILTER_VALIDATE_INT, FILTER_FLAG_GLOBAL_RANGE));
28+
assertType('int|false', filter_var($mixed, FILTER_VALIDATE_INT, ['flags' => FILTER_FLAG_GLOBAL_RANGE]));
29+
}

0 commit comments

Comments
 (0)