@@ -286,6 +286,19 @@ static zend_never_inline int is_protected_compatible_scope(const zend_class_entr
286286}
287287/* }}} */
288288
289+ static zend_never_inline int is_asymmetric_set_protected_property_compatible_scope (const zend_property_info * info , const zend_class_entry * scope ) /* {{{ */
290+ {
291+ zend_class_entry * ce ;
292+ if (info -> hooks && info -> hooks [ZEND_PROPERTY_HOOK_SET ]) {
293+ zend_function * hookfn = info -> hooks [ZEND_PROPERTY_HOOK_SET ];
294+ ce = hookfn -> common .prototype ? hookfn -> common .prototype -> common .scope : hookfn -> common .scope ;
295+ } else {
296+ ce = info -> prototype -> ce ;
297+ }
298+ return is_protected_compatible_scope (ce , scope );
299+ }
300+ /* }}} */
301+
289302static zend_never_inline zend_property_info * zend_get_parent_private_property (zend_class_entry * scope , const zend_class_entry * ce , zend_string * member ) /* {{{ */
290303{
291304 zval * zv ;
@@ -419,7 +432,7 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
419432 }
420433 } else {
421434 ZEND_ASSERT (flags & ZEND_ACC_PROTECTED );
422- if (UNEXPECTED (!is_protected_compatible_scope (property_info -> ce , scope ))) {
435+ if (UNEXPECTED (!is_protected_compatible_scope (property_info -> prototype -> ce , scope ))) {
423436 goto wrong ;
424437 }
425438 }
@@ -514,7 +527,7 @@ ZEND_API zend_property_info *zend_get_property_info(const zend_class_entry *ce,
514527 }
515528 } else {
516529 ZEND_ASSERT (flags & ZEND_ACC_PROTECTED );
517- if (UNEXPECTED (!is_protected_compatible_scope (property_info -> ce , scope ))) {
530+ if (UNEXPECTED (!is_protected_compatible_scope (property_info -> prototype -> ce , scope ))) {
518531 goto wrong ;
519532 }
520533 }
@@ -585,7 +598,7 @@ ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_p
585598 return true;
586599 }
587600 return EXPECTED ((prop_info -> flags & ZEND_ACC_PROTECTED_SET )
588- && is_protected_compatible_scope (prop_info -> ce , scope ));
601+ && is_asymmetric_set_protected_property_compatible_scope (prop_info , scope ));
589602}
590603
591604static void zend_property_guard_dtor (zval * el ) /* {{{ */ {
@@ -2030,7 +2043,7 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend
20302043 zend_class_entry * scope = get_fake_or_executed_scope ();
20312044 if (property_info -> ce != scope ) {
20322045 if (UNEXPECTED (property_info -> flags & ZEND_ACC_PRIVATE )
2033- || UNEXPECTED (!is_protected_compatible_scope (property_info -> ce , scope ))) {
2046+ || UNEXPECTED (!( type == BP_VAR_W || type == BP_VAR_RW ? is_asymmetric_set_protected_property_compatible_scope ( property_info , scope ) : is_protected_compatible_scope (property_info -> prototype -> ce , scope ) ))) {
20342047 if (type != BP_VAR_IS ) {
20352048 zend_bad_property_access (property_info , ce , property_name );
20362049 }
0 commit comments