@@ -7936,11 +7936,16 @@ ZEND_METHOD(ReflectionFiber, getCallable)
79367936 RETURN_COPY (& fiber -> fci .function_name );
79377937}
79387938
7939+ static bool reflection_is_read_only_property (zend_object * object , zend_string * name )
7940+ {
7941+ return zend_hash_exists (& object -> ce -> properties_info , name )
7942+ && (zend_string_equals (name , ZSTR_KNOWN (ZEND_STR_NAME )) || zend_string_equals (name , ZSTR_KNOWN (ZEND_STR_CLASS )));
7943+ }
7944+
79397945/* {{{ _reflection_write_property */
79407946static zval * _reflection_write_property (zend_object * object , zend_string * name , zval * value , void * * cache_slot )
79417947{
7942- if (zend_hash_exists (& object -> ce -> properties_info , name )
7943- && (zend_string_equals (name , ZSTR_KNOWN (ZEND_STR_NAME )) || zend_string_equals (name , ZSTR_KNOWN (ZEND_STR_CLASS ))))
7948+ if (reflection_is_read_only_property (object , name ))
79447949 {
79457950 zend_throw_exception_ex (reflection_exception_ptr , 0 ,
79467951 "Cannot set read-only property %pS::$%pS" , object -> ce -> name , name );
@@ -7951,6 +7956,17 @@ static zval *_reflection_write_property(zend_object *object, zend_string *name,
79517956}
79527957/* }}} */
79537958
7959+ static zval * _reflection_get_property_ptr_ptr (zend_object * object , zend_string * name , int type , void * * cache_slot )
7960+ {
7961+ if (reflection_is_read_only_property (object , name )) {
7962+ zend_throw_exception_ex (reflection_exception_ptr , 0 ,
7963+ "Cannot set read-only property %s::$%s" , ZSTR_VAL (object -> ce -> name ), ZSTR_VAL (name ));
7964+ return & EG (error_zval );
7965+ }
7966+
7967+ return zend_std_get_property_ptr_ptr (object , name , type , cache_slot );
7968+ }
7969+
79547970ZEND_METHOD (ReflectionConstant , __construct )
79557971{
79567972 zend_string * name ;
@@ -8172,6 +8188,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
81728188 reflection_object_handlers .free_obj = reflection_free_objects_storage ;
81738189 reflection_object_handlers .clone_obj = NULL ;
81748190 reflection_object_handlers .write_property = _reflection_write_property ;
8191+ reflection_object_handlers .get_property_ptr_ptr = _reflection_get_property_ptr_ptr ;
81758192 reflection_object_handlers .get_gc = reflection_get_gc ;
81768193
81778194 reflection_exception_ptr = register_class_ReflectionException (zend_ce_exception );
0 commit comments