Category
language
Problem
#101 tracks single-parent extends and empty implements v1. Real PHP controllers and future self-host code also use:
class Child extends Parent_ {
public function run(): void {
parent::greet();
static::factory();
}
}
Without parent:: / static:: lowering, even a minimal extends landing forces duplicated method bodies.
php-src reference
Zend/zend_compile.c — zend_compile_static_call, parent / static class name resolution
Zend/zend_inheritance.c — parent method lookup, zend_get_parent_ce
Zend/zend_class.c — late static binding (Z_CE_SCOPE, called scope)
Zend/zend_vm_execute.h — ZEND_INIT_FCALL / static call opcodes with LSB
Repro (today)
<?php
class Parent_ {
public static function tag(): string { return 'P'; }
public function greet(): string { return 'hi'; }
}
class Child extends Parent_ {
public function run(): string {
return parent::greet() . static::tag();
}
}
echo (new Child())->run();
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
/usr/bin/php repro.php # Zend: hip
This compiler: compile error or wrong dispatch on parent:: / static:: until #101 + this issue land.
Goal
After #101 phase 1a (extends + method lookup chain on VM):
- Compile
parent::method() to parent vtable dispatch
- Compile
static::method() to late-static binding (class of call site, not instance)
- Reject
parent:: on non-methods with clear compile error
Defer: parent::class, parent::$prop, traits (#144).
Scope (this repo)
| Layer |
Files |
Notes |
| Compiler |
lib/Compiler.php |
Expr_StaticCall with parent / static class |
| VM |
lib/VM.php |
Parent chain walk; LSB uses declaring class |
| JIT |
lib/JIT.php |
Defer — VM PHPT first |
| Tests |
test/compliance/cases/classes/ |
parent_method_call.phpt, static_late_binding.phpt |
Done when
Dependencies
Links
Category
languageProblem
#101 tracks single-parent
extendsand emptyimplementsv1. Real PHP controllers and future self-host code also use:Without
parent::/static::lowering, even a minimalextendslanding forces duplicated method bodies.php-src reference
Zend/zend_compile.c—zend_compile_static_call,parent/staticclass name resolutionZend/zend_inheritance.c— parent method lookup,zend_get_parent_ceZend/zend_class.c— late static binding (Z_CE_SCOPE, called scope)Zend/zend_vm_execute.h—ZEND_INIT_FCALL/ static call opcodes with LSBRepro (today)
This compiler: compile error or wrong dispatch on
parent::/static::until #101 + this issue land.Goal
After #101 phase 1a (extends + method lookup chain on VM):
parent::method()to parent vtable dispatchstatic::method()to late-static binding (class of call site, not instance)parent::on non-methods with clear compile errorDefer:
parent::class,parent::$prop, traits (#144).Scope (this repo)
lib/Compiler.phpExpr_StaticCallwithparent/staticclasslib/VM.phplib/JIT.phptest/compliance/cases/classes/parent_method_call.phpt,static_late_binding.phptDone when
hipon VM matching Zend./script/ci-fast.sh --filter 'parent_|static_late'greenDependencies
parent::)Links