Category
stdlib · php-src-strict · spec refresh 2026-06-20
Problem
filter_var() currently implements a very small subset (validate int + validate email) and restricts $options to null|int only. Zend/php-src supports many filters, options arrays, and flag semantics (including FILTER_NULL_ON_FAILURE, FILTER_FLAG_*, FILTER_REQUIRE_ARRAY, default behavior, and correct return types + warnings).
Concrete dispatch failure (2026-06-20 probe)
FILTER_VALIDATE_IP constant resolves to 275, but filter_var('127.0.0.1', FILTER_VALIDATE_IP) emits Warning: filter_var(): Unknown filter with ID 275 and returns false. Zend returns '127.0.0.1.
Related narrow issues: #9588 (named FILTER_* constants rejected at compile), #4934 (FILTER_VALIDATE_BOOL), #9860 (JIT email path).
php-src reference
Repro (today)
<?php
declare(strict_types=1);
// 1) FILTER_VALIDATE_IP — constant known, dispatch missing
var_export(filter_var('127.0.0.1', FILTER_VALIDATE_IP));
echo "\n";
var_export(filter_var('not-an-ip', FILTER_VALIDATE_IP));
echo "\n";
// 2) Options array should be accepted for validate int.
var_export(filter_var('42', FILTER_VALIDATE_INT, ['options' => ['min_range' => 50]]));
echo "\n";
// 3) URL validation is missing.
var_export(filter_var('https://example.com', FILTER_VALIDATE_URL));
echo "\n";
// 4) FILTER_NULL_ON_FAILURE should return null instead of false.
var_export(filter_var('not-an-int', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php 2>&1
'
Expected (Zend):
- IP validate:
'127.0.0.1' / false
false for the min_range case
- URL validate success string or
false
null for FILTER_NULL_ON_FAILURE case
VM today: IP case warns Unknown filter with ID 275; others partial/missing.
Scope (this repo)
| Path |
Work |
ext/filter/ or ext/standard/ |
Register full filter dispatch table |
ext/standard/filter_var.php, VmFilter.php |
VM SSOT per filter |
lib/JIT/ |
defer until VM parity; note in matrix |
| Tests |
test/compliance/cases/stdlib/filter_var_validate_ip.phpt + umbrella PHPTs |
PHP-in-PHP: implement filters in ext/ + shared validation helpers; #9860 shrinks JIT email LLVM after VM parity.
Done when
Related
Category
stdlib· php-src-strict · spec refresh 2026-06-20Problem
filter_var()currently implements a very small subset (validate int + validate email) and restricts$optionstonull|intonly. Zend/php-src supports many filters, options arrays, and flag semantics (includingFILTER_NULL_ON_FAILURE,FILTER_FLAG_*,FILTER_REQUIRE_ARRAY, default behavior, and correct return types + warnings).Concrete dispatch failure (2026-06-20 probe)
FILTER_VALIDATE_IPconstant resolves to275, butfilter_var('127.0.0.1', FILTER_VALIDATE_IP)emitsWarning: filter_var(): Unknown filter with ID 275and returnsfalse. Zend returns'127.0.0.1.Related narrow issues: #9588 (named FILTER_* constants rejected at compile), #4934 (FILTER_VALIDATE_BOOL), #9860 (JIT email path).
php-src reference
ext/filter/filter.c—PHP_FUNCTION(filter_var)+ filter dispatch tableext/filter/logical_filters.c— validation implementationsext/filter/sanitizing_filters.cext/filter/php_filter.h—FILTER_*andFILTER_FLAG_*constantsext/filter/tests/filter_var*.phpt,ext/filter/tests/bug*.phptRepro (today)
Expected (Zend):
'127.0.0.1'/falsefalsefor the min_range casefalsenullfor FILTER_NULL_ON_FAILURE caseVM today: IP case warns Unknown filter with ID 275; others partial/missing.
Scope (this repo)
ext/filter/orext/standard/ext/standard/filter_var.php,VmFilter.phplib/JIT/test/compliance/cases/stdlib/filter_var_validate_ip.phpt+ umbrella PHPTsPHP-in-PHP: implement filters in
ext/+ shared validation helpers; #9860 shrinks JIT email LLVM after VM parity.Done when
filter_var('127.0.0.1', FILTER_VALIDATE_IP)returns validated string (no unknown-filter warning)./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter filter_var'green for new PHPTsphp script/capability-matrix.phpupdatedRelated