Skip to content

Stdlib: filter_var() FILTER_* named filter constants rejected — LogicException not validated value (ext/filter/filter.c) #9588

Description

@PurHur

Category

stdlib · php-src-strict

Problem

filter_var() second argument cannot accept FILTER_* named constants—the VM throws:

LogicException: filter_var() filter must be an integer in this compiler build
Call Zend VM today
filter_var('42', FILTER_VALIDATE_INT) 42 LogicException
filter_var('not-int', FILTER_VALIDATE_INT) false LogicException

Distinct from umbrella #4403 (full ext/filter parity)—this is the constant-binding blocker that prevents any FILTER_* call from working today.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_filter_var_constants.php'
php bin/vm.php test/repro/maintainer_gap_filter_var_constants.php

Implementation hints (PHP-in-PHP)

  • ext/filter/filter_var.php (or ext/standard/ shim) — resolve FILTER_* ints via shared builtin constant helper
  • Register filter constants in StdlibConstants or ext/filter module bootstrap if missing

Done when

  • Repro script matches Zend under VM
  • FILTER_VALIDATE_INT, FILTER_VALIDATE_BOOL, FILTER_SANITIZE_STRING smoke paths work
  • Compliance guard added
  • JIT/AOT agree if filter id lowering exists

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions