Category
language · php-src-strict
Problem
PHP 8.4+ allows write-only hooked properties (public string $x { set => …; } with no get). Reading such a property (including isset() / empty()) must throw a catchable Error — Zend refuses access when no get hook exists. This compiler currently exposes the raw backing value after a set-hook write and reports isset() as true.
Pairs #4821 (get-only → assignment must Error).
php-src reference
Repro (VM today — wrong)
./script/docker-exec.sh -- php bin/vm.php test/repro-maintainer/issue_writeonly_hook_read.php
# prints: HI
./script/docker-exec.sh -- php bin/vm.php test/repro-maintainer/issue_writeonly_hook_isset.php
# prints: bool(true)
Zend PHP 8.4+ (host comparison when available):
<?php
class C {
public string $x {
set => $this->x = strtoupper($value);
}
}
$c = new C();
$c->x = 'hi';
try { echo $c->x, "\n"; } catch (Error $e) { echo $e->getMessage(), "\n"; }
try { var_dump(isset($c->x)); } catch (Error $e) { echo $e->getMessage(), "\n"; }
Expected
echo $c->x → Error: Cannot read property C::$x without get hook (wording per Zend)
isset($c->x) / empty($c->x) → same Error (no silent true)
Implementation hints (PHP-in-PHP)
- VM:
lib/VM.php property-hook fetch / isset paths — reject when hook metadata has set but no get (lib/VM/PropertyHookSupport.php or equivalent)
- JIT/AOT: mirror in
lib/JIT/PropertyHookDispatch.php (compliance JIT/AOT when issue requires)
- Add
test/compliance/cases/language/property_hook_writeonly_read.phpt + property_hook_writeonly_isset.phpt
Verification
./script/docker-exec.sh -- php bin/vm.php test/repro-maintainer/issue_writeonly_hook_read.php
./script/ci-fast.sh --filter 'property_hook_writeonly'
Category
language· php-src-strictProblem
PHP 8.4+ allows write-only hooked properties (
public string $x { set => …; }with noget). Reading such a property (includingisset()/empty()) must throw a catchableError— Zend refuses access when no get hook exists. This compiler currently exposes the raw backing value after a set-hook write and reportsisset()astrue.Pairs #4821 (get-only → assignment must Error).
php-src reference
Zend/zend_property_hooks.c—zend_property_get_hook()whengethook is absentZend/zend_object_handlers.c—isset/ read paths on hooked propertiesRepro (VM today — wrong)
Zend PHP 8.4+ (host comparison when available):
Expected
echo $c->x→Error: Cannot read property C::$x without get hook(wording per Zend)isset($c->x)/empty($c->x)→ same Error (no silenttrue)Implementation hints (PHP-in-PHP)
lib/VM.phpproperty-hook fetch /issetpaths — reject when hook metadata has set but no get (lib/VM/PropertyHookSupport.phpor equivalent)lib/JIT/PropertyHookDispatch.php(compliance JIT/AOT when issue requires)test/compliance/cases/language/property_hook_writeonly_read.phpt+property_hook_writeonly_isset.phptVerification
./script/docker-exec.sh -- php bin/vm.php test/repro-maintainer/issue_writeonly_hook_read.php ./script/ci-fast.sh --filter 'property_hook_writeonly'