You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ReflectionProperty::getRawValue() and related methods may call hooks of overridden properties #17713
ReflectionProperty::getRawValue(), ::setRawValue(), ::setRawValueWithoutLazyInitialization() may call hooks when they reference a property of a parent class, that was overridden in the actual class, with hooks.
The following code:
class A {
public$a = 'A::$a';
}
class B extends A {
public$a = 'B::$a' {
get { printf("Called hook: %s\n", __METHOD__); return$this->a; }
set { printf("Called hook: %s\n", __METHOD__); $field = $value; }
}
}
// Reference A::a$r = newReflectionProperty(A::class, 'a');
// Access B::avar_dump($r->getRawValue(newB()));
Thank you! Small note: I think the set hook here has no effect. It also writes to $field, which I'm not sure is intentional (it used to refer to the property backing value in an old draft).
Activity
iluuu1994 commentedon Feb 6, 2025
Thank you! Small note: I think the
sethook here has no effect. It also writes to$field, which I'm not sure is intentional (it used to refer to the property backing value in an old draft).arnaud-lb commentedon Feb 6, 2025
You are right! The
sethooks is a copy/paste from an old test, and has no effect.iluuu1994 commentedon Feb 6, 2025
@arnaud-lb Ah, I see! ext/reflection/tests/property_hooks/ReflectionProperty_getSetRawValue.phpt is wrong.
arnaud-lb commentedon Feb 6, 2025
This is the one I copied from :) But this is not really important as the hooks are not supposed to be called in this test or in the example
Fix ReflectionProperty::getRawValue() and related methods for propert…