Skip to content

php-in-php: JIT StringFilterEmail — route FILTER_VALIDATE_EMAIL through VmFilter PHP not ~343-line LLVM (#4742, #1492) #9860

Description

@PurHur

Category

php-in-php · php-src-strict

Problem

Email validation for filter_var($v, FILTER_VALIDATE_EMAIL) is implemented in PHP (ext/filter/VmFilter.php — validateEmail()), but JIT/AOT duplicate the regex/token rules in lib/JIT/Builtin/StringFilterEmail.php (~343 lines of LLVM).

Same SSOT problem as #9858 (boolean parse): two implementations drift on edge cases (IDN, quoted local-part, etc.).

php-src reference

Repro

<?php
$cases = [
    ['user@example.com', 'user@example.com'],
    ['bad', false],
    ['', false],
];
foreach ($cases as [$in, $want]) {
    $got = filter_var($in, FILTER_VALIDATE_EMAIL);
    echo "$in => ", var_export($got, true), ($got == $want) ? " OK\n" : " FAIL\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_filter_email.php
php bin/jit.php test/repro/maintainer_filter_email.php
'

Scope

Path Work
ext/filter/FilterEmailJitHelper.php (new) Bridge → VmFilter::validateEmail()
lib/JIT/Builtin/StringFilterEmail.php Thin LLVM wrapper only
Tests extend filter_var compliance (#4742)

Done when

  • JIT/AOT repro matches VM/Zend table
  • StringFilterEmail.php reduced to thin bridge (−300+ LLVM lines)
  • Enum case operands still TypeError via shared guards
  • ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter FilterEmail' green

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:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions