Category
stdlib | language · php-src-strict (PHP 8.4)
Problem
PHP 8.4 adds ReflectionProperty::setRawValue(object $object, mixed $value) and getRawValue(object $object): mixed to read/write backing storage without invoking property hooks. Required for serializers, ORMs, and tests that initialize hooked properties before hooks are wired.
This compiler has property-hook VM dispatch (#4687, #6427) but no ReflectionProperty raw-value API — method_exists(ReflectionProperty::class, 'setRawValue') is false under bin/vm.php.
php-src reference
Repro (failure today)
Save as test/repro/maintainer_reflection_property_raw_value.php:
<?php
class Box {
private string $label = 'init';
public string $name {
get => strtoupper($this->label);
set => $this->label = strtolower($value);
}
}
$o = new Box();
$rp = new ReflectionProperty(Box::class, 'name');
if (!method_exists($rp, 'setRawValue')) {
echo "missing setRawValue\n";
exit(1);
}
$rp->setRawValue($o, 'RAW');
echo $o->name, "\n"; // hook get => STRtoupper('RAW') => 'RAW' if backing updated
echo $rp->getRawValue($o), "\n"; // Zend: 'RAW' (backing field)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_reflection_property_raw_value.php 2>&1 | head -5
# missing setRawValue / exit 1
'
| Step |
Zend PHP 8.4 |
VM today |
method_exists(..., setRawValue) |
true |
false ❌ |
After setRawValue($o, 'RAW') |
getRawValue → 'RAW'; ->name uses get hook |
n/a |
Scope (this repo)
| Path |
Work |
ext/reflection/ or lib/VM/BuiltinClasses.php |
Register setRawValue / getRawValue on ReflectionProperty |
lib/VM/PropertyHookSupport.php |
Write/read backing slot without invoking hooks |
| Tests |
test/compliance/cases/stdlib/reflection_property_raw_value.phpt |
PHP-in-PHP: reflection methods in PHP/VM; no new runtime/*.c.
Done when
Related: instance hooks #4687, static hooks #9520, #1492
Category
stdlib|language· php-src-strict (PHP 8.4)Problem
PHP 8.4 adds
ReflectionProperty::setRawValue(object $object, mixed $value)andgetRawValue(object $object): mixedto read/write backing storage without invoking property hooks. Required for serializers, ORMs, and tests that initialize hooked properties before hooks are wired.This compiler has property-hook VM dispatch (#4687, #6427) but no ReflectionProperty raw-value API —
method_exists(ReflectionProperty::class, 'setRawValue')is false underbin/vm.php.php-src reference
ext/reflection/php_reflection.c—reflection_property_set_raw_value,reflection_property_get_raw_valueZend/zend_property_hooks.c— raw storage access bypassing get/set hooksext/reflection/php_reflection.stub.php— PHP 8.4 signaturesext/reflection/tests/ReflectionProperty_setRawValue*.phpt(php-src 8.4+)Repro (failure today)
Save as
test/repro/maintainer_reflection_property_raw_value.php:method_exists(..., setRawValue)truefalse❌setRawValue($o, 'RAW')getRawValue→'RAW';->nameuses get hookScope (this repo)
ext/reflection/orlib/VM/BuiltinClasses.phpsetRawValue/getRawValueonReflectionPropertylib/VM/PropertyHookSupport.phptest/compliance/cases/stdlib/reflection_property_raw_value.phptPHP-in-PHP: reflection methods in PHP/VM; no new
runtime/*.c.Done when
method_exists(ReflectionProperty::class, 'setRawValue')true on VMsetRawValueupdates backing;get()still runs get hook;getRawValuereturns backingReflectionException/TypeError./script/ci-fast.sh --filter reflection_property_rawgreenRelated: instance hooks #4687, static hooks #9520, #1492