Problem
lib/VM/Variable.php throws for many equality pairs:
Equals comparison between {type} and {type} not implemented
Routers and guards frequently compare strings to literals, or mixed int/string from $_GET:
if ($ _GET ['page ' ] === 'admin ' ) { . .. }
if ($ route == 1 ) { . .. }
JIT may lack lowering for === / == on some type pairs even when VM works. Blocks #210 route tables and #270 JSON guard patterns.
Goal
Complete comparison operators (==, ===, !=, <, >, <=, >=) for web-common type pairs: string/string, string/int, int/int, bool/bool, null checks.
Implementation hints
Audit first
rg " not implemented" lib/VM/Variable.php
rg " TYPE_IS_EQUAL|TYPE_IS_IDENTICAL" lib/JIT.php lib/Compiler.php
Variable::equals() (~line 368) and compareOp() (~441) — extend switch arms before adding JIT.
VM (lib/VM/Variable.php)
string === string: byte-wise compare (Zend uses binary-safe; match PHP for ASCII routes)
string == int: PHP coercion rules — add PHPT table in test/real/cases/compare_mixed.phpt
null === null: already partial; ensure $_GET['missing'] undefined key behavior aligns with Runtime: Undefined array/superglobal key — Zend notice parity #273 before strict compares
JIT (lib/JIT.php)
Search assignop / compare lowering for Op\Expr\BinaryOp\Equal / Identical
Reuse string compare helpers from existing concat/strlen JIT paths
Order: === string/string first (routing), then loose == for query params
AOT
Same LLVM paths as JIT once opcode coverage lands
Tasks
Acceptance criteria
docker run --rm -v " $( pwd) :/compiler" -w /compiler php-compiler:22.04-dev \
./phpc run -r ' var_export("1" === "1");'
if ($route === 'home') and if ($_GET['id'] === '1') work in VM, JIT, and AOT.
Key files
lib/VM/Variable.php — equals(), compareOp(), _compareOp()
lib/JIT.php — binary compare opcodes
lib/Compiler.php — expr lowering for Equal / Identical
Dependencies
Verification (local only)
./script/ci-local.sh --filter compare
Related
Problem
lib/VM/Variable.phpthrows for many equality pairs:Routers and guards frequently compare strings to literals, or mixed int/string from
$_GET:JIT may lack lowering for
===/==on some type pairs even when VM works. Blocks #210 route tables and #270 JSON guard patterns.Goal
Complete comparison operators (
==,===,!=,<,>,<=,>=) for web-common type pairs: string/string, string/int, int/int, bool/bool, null checks.Implementation hints
Audit first
Variable::equals()(~line 368) andcompareOp()(~441) — extendswitcharms before adding JIT.VM (
lib/VM/Variable.php)test/real/cases/compare_mixed.phpt$_GET['missing']undefined key behavior aligns with Runtime: Undefined array/superglobal key — Zend notice parity #273 before strict comparesJIT (
lib/JIT.php)Op\Expr\BinaryOp\Equal/Identical===string/string first (routing), then loose==for query paramsAOT
Tasks
Variable::equalsandcompareOpuncovered pairs; list in PR$_GET['id'] === '1'Acceptance criteria
if ($route === 'home')andif ($_GET['id'] === '1')work in VM, JIT, and AOT.Key files
lib/VM/Variable.php—equals(),compareOp(),_compareOp()lib/JIT.php— binary compare opcodeslib/Compiler.php— expr lowering forEqual/IdenticalDependencies
===with missing keys)??(orthogonal; use together in apps)Verification (local only)
Related