Problem
Expr_Instanceof_ is not handled in lib/Compiler.php (Unsupported expression). Web apps and templates eventually need guards like:
if ($handler instanceof Router) { /* … */ }
Not required for 003-MiniWebApp v1 (no instanceof in tree), but blocks framework-style routing and plugin checks.
Goal
$obj instanceof MyClass for simple named classes (no union types, no interfaces in v1).
class Box {}
$o = new Box();
var_export($o instanceof Box); // true
var_export($o instanceof stdClass); // false
VM + JIT + AOT parity with Zend for declared classes.
Implementation hints
| Layer |
Files |
Notes |
| Compiler |
lib/Compiler.php compileExpr |
New opcode TYPE_INSTANCEOF or reuse class-id compare after #58 object headers |
| VM |
lib/VM.php |
Compare object ClassEntry name/id to rhs class literal |
| JIT |
lib/JIT.php, lib/JIT/Builtin/Type/Object_.php |
LLVM icmp on class id when objects JIT-supported |
| Lint |
lib/Lint/UnsupportedRegistry.php |
Map Expr_Instanceof until implemented |
| AOT |
lib/AOT/ |
Same metadata as VM class table |
Tests
test/compliance/cases/language/instanceof_class.phpt
- Negative: unrelated class name → false
@group llvm JIT/AOT stages in ci-local.sh
Acceptance criteria
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
vendor/bin/phpunit test/compliance/cases/language/instanceof_class.phpt
Verification (local / Docker only)
./script/ci-fast.sh --filter instanceof
Dependencies
Priority
P2 — after #67 reference app and #58 OOP land.
Links
Problem
Expr_Instanceof_is not handled inlib/Compiler.php(Unsupported expression). Web apps and templates eventually need guards like:Not required for 003-MiniWebApp v1 (no
instanceofin tree), but blocks framework-style routing and plugin checks.Goal
$obj instanceof MyClassfor simple named classes (no union types, no interfaces in v1).VM + JIT + AOT parity with Zend for declared classes.
Implementation hints
lib/Compiler.phpcompileExprTYPE_INSTANCEOFor reuse class-id compare after #58 object headerslib/VM.phpClassEntryname/id to rhs class literallib/JIT.php,lib/JIT/Builtin/Type/Object_.phpicmpon class id when objects JIT-supportedlib/Lint/UnsupportedRegistry.phpExpr_Instanceofuntil implementedlib/AOT/Tests
test/compliance/cases/language/instanceof_class.phpt@group llvmJIT/AOT stages inci-local.shAcceptance criteria
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \ vendor/bin/phpunit test/compliance/cases/language/instanceof_class.phptVerification (local / Docker only)
Dependencies
Priority
P2 — after #67 reference app and #58 OOP land.
Links