Category
language · php-src-strict · PHP 8.4 property hooks
Problem
For a get-only hooked property (no backing field, hook returns a value):
class C {
public int $x {
get => 1;
}
}
Zend routes isset($c->x) and empty($c->x) through the get hook (value 1 → isset true, empty false).
This compiler skips the hook:
isset($c->x) → false
empty($c->x) → true
Distinct from #9696 (initialized private backing + get/set hooks) which failed compile due to #9830-class redeclare errors.
php-src reference
Repro (failure today)
<?php
class C {
public int $x {
get => 1;
}
}
$c = new C();
var_dump(isset($c->x));
var_dump(empty($c->x));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro_getonly_hook_isset.php
'
| Engine |
isset |
empty |
| Zend PHP 8.4+ |
true |
false |
| VM today |
false |
true |
Scope
lib/VM.php — isset / empty opcodes on hooked properties without backing
lib/JIT.php — mirror VM when JIT lowers isset/empty on hooks
test/compliance/cases/language/property_hook_getonly_isset_empty.phpt
Done when
Related
Category
language· php-src-strict · PHP 8.4 property hooksProblem
For a get-only hooked property (no backing field, hook returns a value):
Zend routes
isset($c->x)andempty($c->x)through the get hook (value1→issettrue,emptyfalse).This compiler skips the hook:
isset($c->x)→ falseempty($c->x)→ trueDistinct from #9696 (initialized private backing + get/set hooks) which failed compile due to #9830-class redeclare errors.
php-src reference
Zend/zend_property_hooks.c—isset/emptyon virtual propertiesRepro (failure today)
issetemptytruefalsefalsetrueScope
lib/VM.php—isset/emptyopcodes on hooked properties without backinglib/JIT.php— mirror VM when JIT lowers isset/empty on hookstest/compliance/cases/language/property_hook_getonly_isset_empty.phptDone when
./script/ci-fast.sh --filter property_hook_getonly_issetgreenRelated