Category
language
Problem
PHP 8.4 property hooks must participate in list destructuring and array destructuring ([$obj->prop] = …, […, $obj->prop, …] = …). Zend invokes the set hook on assignment targets and the get hook when a hooked property is read as a destructuring source.
This compiler lowers hooks via lib/SourcePreprocessor/PropertyHooks.php + indirect writes in lib/VM.php, but list/array destructuring still writes backing storage (or skips hooks), diverging from php-src.
Pairs with #6426 (by-ref assign), #6427 (compound assign), #6424 (++/--) — same zend_property_hooks.c dispatch family.
php-src reference
Repro
Save as test/repro-maintainer/parity_property_hook_list_destructure.php:
<?php
class Box {
private string $_v = '';
public string $label {
get => $this->_v;
set => $this->_v = '[' . $value . ']';
}
}
$c = new Box();
[$c->label] = ['hi'];
echo $c->label, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_property_hook_list_destructure.php
php bin/vm.php test/repro-maintainer/parity_property_hook_list_destructure.php
'
| Runtime |
Output |
| Zend PHP 8.4+ |
[hi] (set hook ran) |
| VM today |
likely hi or hook bypass (wrong) |
Compliance: add test/compliance/cases/language/property_hook_list_destructure.phpt
Scope (this repo)
| Path |
Work |
lib/VM.php |
List/assign lowering — route hooked property lvalues through set hook |
lib/JIT/PropertyHookDispatch.php |
Mirror for JIT/AOT when destructuring is lowered |
lib/Compiler.php |
Ensure list targets on hooked props emit hook-aware stores |
| Tests |
VM + JIT PHPT (JIT may defer if Block::requiresVmLowering) |
PHP-in-PHP first — no new C runtime branches.
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter property_hook_list'
Related
Category
languageProblem
PHP 8.4 property hooks must participate in list destructuring and array destructuring (
[$obj->prop] = …,[…, $obj->prop, …] = …). Zend invokes the set hook on assignment targets and the get hook when a hooked property is read as a destructuring source.This compiler lowers hooks via
lib/SourcePreprocessor/PropertyHooks.php+ indirect writes inlib/VM.php, but list/array destructuring still writes backing storage (or skips hooks), diverging from php-src.Pairs with #6426 (by-ref assign), #6427 (compound assign), #6424 (++/--) — same
zend_property_hooks.cdispatch family.php-src reference
Zend/zend_property_hooks.c— hooked lvalue assignment pathsZend/zend_execute.c—ZEND_ASSIGN_DIM, list assign opcodesZend/zend_compile.c— destructuring compileRepro
Save as
test/repro-maintainer/parity_property_hook_list_destructure.php:[hi](set hook ran)hior hook bypass (wrong)Compliance: add
test/compliance/cases/language/property_hook_list_destructure.phptScope (this repo)
lib/VM.phplib/JIT/PropertyHookDispatch.phplib/Compiler.phpBlock::requiresVmLowering)PHP-in-PHP first — no new C runtime branches.
Done when
[hi]on VM matching Zend./script/ci-fast.sh --filter property_hook_listgreenVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter property_hook_list'Related