Skip to content

Commit b4f3ef5

Browse files
phpstan-botclaude
andcommitted
Add FilterVarRule test for FILTER_FLAG_GLOBAL_RANGE on PHP 8.5+
Ensures FILTER_FLAG_GLOBAL_RANGE|FILTER_NULL_ON_FAILURE does not falsely trigger the "cannot use both" error on PHP 8.5+ where the constants have distinct values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 001b55d commit b4f3ef5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/PHPStan/Rules/Functions/FilterVarRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@ public function testRuleWithGlobalRange(): void
3737
$this->analyse([__DIR__ . '/data/filter_var_null_and_throw_global_range.php'], []);
3838
}
3939

40+
#[RequiresPhp('>= 8.5')]
41+
public function testRuleGlobalRangePhp85(): void
42+
{
43+
$this->analyse([__DIR__ . '/data/filter_var_null_and_global_range_php85.php'], []);
44+
}
45+
4046
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php // lint >= 8.5
2+
3+
namespace FilterVarNullAndGlobalRangePhp85;
4+
5+
filter_var('foo@bar.test', FILTER_VALIDATE_EMAIL, FILTER_FLAG_GLOBAL_RANGE|FILTER_NULL_ON_FAILURE);
6+
7+
$flag = FILTER_NULL_ON_FAILURE|FILTER_FLAG_GLOBAL_RANGE;
8+
filter_var(100, FILTER_VALIDATE_INT, $flag);
9+
10+
filter_var(
11+
'johndoe',
12+
FILTER_VALIDATE_REGEXP,
13+
['options' => ['regexp' => '/^[a-z]+$/'], 'flags' => FILTER_FLAG_GLOBAL_RANGE|FILTER_NULL_ON_FAILURE]
14+
);

0 commit comments

Comments
 (0)