Skip to content

Commit a3ff956

Browse files
ondrejmirtesclaude
andcommitted
Allow FILTER_THROW_ON_FAILURE in $options of filter_var() and filter_input()
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SCH8hvECi7zaEUr1Get7sG
1 parent 8f06875 commit a3ff956

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎resources/constantToFunctionParameterMap.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@
657657
'FILTER_FLAG_GLOBAL_RANGE',
658658
'FILTER_FLAG_HOSTNAME',
659659
'FILTER_FLAG_EMAIL_UNICODE',
660+
'FILTER_THROW_ON_FAILURE',
660661
],
661662
],
662663
],
@@ -730,6 +731,7 @@
730731
'FILTER_FLAG_GLOBAL_RANGE',
731732
'FILTER_FLAG_HOSTNAME',
732733
'FILTER_FLAG_EMAIL_UNICODE',
734+
'FILTER_THROW_ON_FAILURE',
733735
],
734736
],
735737
],

‎tests/PHPStan/Rules/Functions/data/constant-parameter-check.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,8 @@ public function hashPassword(string $password): string
120120

121121
// preg_replace_callback_array: correct constant in $flags
122122
preg_replace_callback_array(['/foo/' => fn ($m) => $m[0]], 'subject', -1, $count, PREG_UNMATCHED_AS_NULL);
123+
124+
// filter_var/filter_input: FILTER_THROW_ON_FAILURE is a valid flag (PHP 8.5)
125+
filter_var('foo', FILTER_VALIDATE_INT, FILTER_THROW_ON_FAILURE);
126+
filter_var('foo', FILTER_VALIDATE_INT, FILTER_THROW_ON_FAILURE | FILTER_FLAG_ALLOW_HEX);
127+
filter_input(INPUT_GET, 'foo', FILTER_VALIDATE_INT, FILTER_THROW_ON_FAILURE);

0 commit comments

Comments
 (0)