Expose zend_reflection_property_set_raw_value, zend_reflection_property_set_raw_value_without_lazy_initialization#21763
Conversation
…ty_set_raw_value_without_lazy_initialization
…lable
PHP 8.6 exposes zend_reflection_property_set_raw_value{,_without_lazy_initialization}
as PHPAPI (php/php-src#21763), moving the lazy-prop
bookkeeping into ext/reflection. Use the PHPAPI direct on 8.6+ and keep the
userland ReflectionProperty round-trip as a fallback for 8.4 / 8.5.
Depends on php/php-src#21763 landing; holding here until the patch is merged
and the target PHP version is known.
…lable
PHP 8.6 exposes zend_reflection_property_set_raw_value{,_without_lazy_initialization}
as PHPAPI (php/php-src#21763), moving the lazy-prop
bookkeeping into ext/reflection. Use the PHPAPI direct on 8.6+ and keep the
userland ReflectionProperty round-trip as a fallback for 8.4 / 8.5.
Depends on php/php-src#21763 landing; holding here until the patch is merged
and the target PHP version is known.
|
Not sure the current interface is the best to expose, e.g. the What is the issue with having other extensions just call the reflection methods via the normal mechanism for calling class methods? |
CPU overhead! |
|
@DanielEScherzer I've documented the If you prefer, I can change the API to something like this: typedef reflection_object zend_reflection_property;
PHPAPI zend_reflection_property *zend_reflection_property_create(zend_class_entry *ce, zend_string *name);
PHPAPI void zend_reflection_property_set_raw_value(zend_reflection_property *refl_prop, zend_object *object, zval *value);
In addition to being faster, this also provides a nicer API. Instantiating objects and calling methods is not straightforward in C. |
…lable
PHP 8.6 exposes zend_reflection_property_set_raw_value{,_without_lazy_initialization}
as PHPAPI (php/php-src#21763), moving the lazy-prop
bookkeeping into ext/reflection. Use the PHPAPI direct on 8.6+ and keep the
userland ReflectionProperty round-trip as a fallback for 8.4 / 8.5.
Depends on php/php-src#21763 landing; holding here until the patch is merged
and the target PHP version is known.
|
The other thing to mention is calling a "PHP" function/method from C AFAIK requires setting up new VM stacks compared to "just" running in a loop. The other thing is that for global functions those can be disabled by an INI setting. (For classes and class methods that's no longer an issue since 8.5 as the disable_class INI setting got removed) |
This exposes the functionality of
ReflectionProperty::setRawValue()andReflectionProperty::setRawValueWithoutLazyInitialiation()to C extensions.Test failure unrelated.