Frameworks (Symfony PropertyInfo, Laravel attribute scanners) need hook introspection separate from #4469 getValue/setValue and #4806-adjacent #10392 isset/empty semantics.
<?php
declare(strict_types=1);
class Box {
public string $label {
get => strtoupper($this->label);
set (string $v) { $this->label = $v; }
}
private string $label = 'hi';
}
$rp = new ReflectionProperty(Box::class, 'label');
echo method_exists($rp, 'getHooks') ? "getHooks yes\n" : "getHooks no\n";
echo method_exists($rp, 'setHook') ? "setHook yes\n" : "setHook no\n";
if (method_exists($rp, 'getHooks')) {
$hooks = $rp->getHooks();
ksort($hooks);
echo implode(',', array_keys($hooks)), "\n";
}
$b = new Box();
echo $b->label, "\n";
if (method_exists($rp, 'setHook')) {
$rp->setHook('get', fn() => 'OVERRIDE');
echo $b->label, "\n";
}
Category
stdlib· php-src-strict · spec refresh 2026-06-20Problem
PHP 8.4
ReflectionProperty::getHooks(): arrayandsetHook(string $name, Closure $hook)expose property hook callables for introspection. This compiler lowers hooks to__phpc_property_*methods (#3145) but ReflectionProperty has nogetHooks/setHookbuiltins —method_exists($rp, 'getHooks')is false underbin/vm.php.Frameworks (Symfony PropertyInfo, Laravel attribute scanners) need hook introspection separate from #4469 getValue/setValue and #4806-adjacent #10392 isset/empty semantics.
php-src reference
ext/reflection/php_reflection.c—ReflectionProperty::getHooks,setHookext/reflection/php_reflection.stub.php— PHP 8.4 signaturesZend/zend_property_hooks.c— hook storagelib/SourcePreprocessor/PropertyHooks.php,lib/VM.phplinkPropertyHooksRepro
Commit
test/repro/maintainer_reflection_property_gethooks.php:method_exists(..., 'getHooks')truefalse❌method_exists(..., 'setHook')truefalse❌getHooks()keysget,set$b->labelbefore overrideHIsetHook('get', …)OVERRIDEScope (PHP-in-PHP)
ext/standard/VmReflection.php—ReflectionProperty::getHooks,setHooklib/VM/BuiltinClasses.php— register methods onReflectionPropertyClassProperty/staticPropertyHooksonClassEntrytest/compliance/cases/stdlib/reflection_property_hooks.phptscript/capability-matrix.phpDone when (php-src-strict)
getHooks()returnsget+setentriessetHook('get', $closure)changes subsequent reads on live objectValueErrorlike Zend./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter reflection_property_hooks'green./script/ci-fast.sh --filter reflection_property_hooksgreenRelated