forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-14397.php
More file actions
29 lines (22 loc) · 827 Bytes
/
bug-14397.php
File metadata and controls
29 lines (22 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php // lint >= 8.2
declare(strict_types = 1);
namespace Bug14397;
use PHPStan\TrinaryLogic;
use function filter_var;
use function PHPStan\Testing\assertType;
use function PHPStan\Testing\assertVariableCertainty;
function test(string $ipAddress): void
{
assertType('non-falsy-string|false', filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_GLOBAL_RANGE));
}
function test2(mixed $mixed): void
{
try {
filter_var($mixed, FILTER_VALIDATE_INT, FILTER_FLAG_GLOBAL_RANGE);
$foo = 1;
} catch (\Filter\FilterFailedException $e) {
assertVariableCertainty(TrinaryLogic::createYes(), $foo);
}
assertType('int|false', filter_var($mixed, FILTER_VALIDATE_INT, FILTER_FLAG_GLOBAL_RANGE));
assertType('int|false', filter_var($mixed, FILTER_VALIDATE_INT, ['flags' => FILTER_FLAG_GLOBAL_RANGE]));
}