What
Under AOT, a property default declared on a parent class is not applied when a subclass is instantiated. Instantiating the parent directly works, so this is specific to inheritance.
Both typed and untyped properties are affected. The untyped case degrades to a warning plus empty output, which is the silent-wrong-output class this project treats as the characteristic bug (AGENTS.md §3).
Repro
<?php
class A { public string $p = 'hi'; }
class B extends A {}
echo (new B)->p;
Measured in php-compiler:22.04-dev, on a tree containing the AOT link fix from #31894 (without it nothing links at all):
| case |
Zend 8.2.32 |
AOT |
class A { public string $p = 'hi'; } (new A)->p |
hi |
hi ✓ |
class B extends A {} (new B)->p — typed |
hi |
PHP Fatal error: Uncaught Error: Typed property A::$p must not be accessed before initialization |
class B extends A {} (new B)->p — untyped |
hi |
PHP Warning: Undefined property: A::$p then empty |
Note the error names A::$p — the declaring class — so the property appears to be registered against the parent while the subclass's instance initialisation never writes the default.
Why it matters
This is not an edge case. Any class hierarchy where a base class declares a property with a default is broken under AOT, which is most real PHP code. The untyped variant produces wrong output rather than an error, so a program can silently compute the wrong answer.
How it was found
Two other AOT defects reported around the same time — var_dump aborting with rc=134 and Exception::getMessage() segfaulting — turned out to be symptoms of the duplicate-memset link failure in #31894 and now match Zend exactly. This one survives that fix and is independent.
Done when
class A { public string $p = 'hi'; } class B extends A {} echo (new B)->p; prints hi under AOT
- the untyped variant likewise prints
hi with no warning
- a compliance case covers both, plus a two-level hierarchy (
C extends B extends A)
What
Under AOT, a property default declared on a parent class is not applied when a subclass is instantiated. Instantiating the parent directly works, so this is specific to inheritance.
Both typed and untyped properties are affected. The untyped case degrades to a warning plus empty output, which is the silent-wrong-output class this project treats as the characteristic bug (AGENTS.md §3).
Repro
Measured in
php-compiler:22.04-dev, on a tree containing the AOT link fix from #31894 (without it nothing links at all):class A { public string $p = 'hi'; } (new A)->phihi✓class B extends A {} (new B)->p— typedhiPHP Fatal error: Uncaught Error: Typed property A::$p must not be accessed before initializationclass B extends A {} (new B)->p— untypedhiPHP Warning: Undefined property: A::$pthen emptyNote the error names
A::$p— the declaring class — so the property appears to be registered against the parent while the subclass's instance initialisation never writes the default.Why it matters
This is not an edge case. Any class hierarchy where a base class declares a property with a default is broken under AOT, which is most real PHP code. The untyped variant produces wrong output rather than an error, so a program can silently compute the wrong answer.
How it was found
Two other AOT defects reported around the same time —
var_dumpaborting with rc=134 andException::getMessage()segfaulting — turned out to be symptoms of the duplicate-memsetlink failure in #31894 and now match Zend exactly. This one survives that fix and is independent.Done when
class A { public string $p = 'hi'; } class B extends A {} echo (new B)->p;printshiunder AOThiwith no warningC extends B extends A)