@@ -584,65 +584,22 @@ ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *cal
584584#define ZEND_CLASS_HAS_TYPE_HINTS (ce ) ((bool)(ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS))
585585#define ZEND_CLASS_HAS_READONLY_PROPS (ce ) ((bool)(ce->ce_flags & ZEND_ACC_HAS_READONLY_PROPS))
586586
587- static zend_always_inline bool zend_has_active_ctor_with_promoted_property (
588- const zend_execute_data * ex , zend_object * obj , zend_string * property_name )
589- {
590- for (const zend_execute_data * frame = ex ; frame != NULL ; frame = frame -> prev_execute_data ) {
591- if (!(ZEND_CALL_INFO (frame ) & ZEND_CALL_HAS_THIS ) || Z_OBJ (frame -> This ) != obj ) {
592- return false;
593- }
594- if (!(frame -> func -> common .fn_flags & ZEND_ACC_CTOR )) {
595- continue ;
596- }
597-
598- zend_class_entry * scope = frame -> func -> common .scope ;
599- ZEND_ASSERT (scope );
600-
601- zend_property_info * scope_prop = (zend_property_info * ) zend_hash_find_ptr (& scope -> properties_info , property_name );
602- ZEND_ASSERT (scope_prop );
603- return scope_prop -> ce == scope && (scope_prop -> flags & (ZEND_ACC_READONLY |ZEND_ACC_PROMOTED )) == (ZEND_ACC_READONLY |ZEND_ACC_PROMOTED );
604- }
605-
606- return false;
607- }
608-
609587typedef enum _zend_property_write_kind {
610588 ZEND_PROPERTY_WRITE_FORBIDDEN = 0 , /* Write disallowed */
611589 ZEND_PROPERTY_WRITE_OK , /* Write allowed */
612590 ZEND_PROPERTY_WRITE_READONLY_REINITABLE , /* Clone reinit window: clear IS_PROP_REINITABLE after write */
613591 ZEND_PROPERTY_WRITE_READONLY_CTOR_REASSIGNED , /* CPP ctor reassignment: set IS_PROP_CTOR_REASSIGNED after write */
614592} zend_property_write_kind ;
615593
616- static zend_always_inline zend_property_write_kind zend_get_readonly_write_kind (
617- const zval * property_val , const zend_property_info * prop_info )
618- {
619- if (Z_PROP_FLAG_P (property_val ) & IS_PROP_REINITABLE ) {
620- return ZEND_PROPERTY_WRITE_READONLY_REINITABLE ;
621- }
622- if (Z_PROP_FLAG_P (property_val ) & IS_PROP_CTOR_REASSIGNED ) {
623- return ZEND_PROPERTY_WRITE_FORBIDDEN ;
624- }
625- zend_execute_data * ex = EG (current_execute_data );
626- if (ex == NULL || !(ZEND_CALL_INFO (ex ) & ZEND_CALL_HAS_THIS )) {
627- return ZEND_PROPERTY_WRITE_FORBIDDEN ;
628- }
629- zend_object * obj = zend_get_object_from_slot (property_val , prop_info );
630- if (!zend_has_active_ctor_with_promoted_property (ex , obj , prop_info -> name )
631- || (ex -> opline
632- && (ex -> opline -> opcode == ZEND_ASSIGN_OBJ || ex -> opline -> opcode == ZEND_ASSIGN_OBJ_REF )
633- && (ex -> opline -> extended_value & ZEND_ASSIGN_OBJ_PROMOTED_READONLY_INIT ))) {
634- return ZEND_PROPERTY_WRITE_FORBIDDEN ;
635- }
636- return ZEND_PROPERTY_WRITE_READONLY_CTOR_REASSIGNED ;
637- }
594+ ZEND_API ZEND_COLD zend_property_write_kind zend_verify_readonly_slow (zval * property_val , const zend_property_info * info );
638595
639596static zend_always_inline zend_property_write_kind zend_verify_readonly_and_avis (
640597 zval * property_val , const zend_property_info * info , bool indirect )
641598{
642599 if (UNEXPECTED (info -> flags & (ZEND_ACC_READONLY |ZEND_ACC_PPP_SET_MASK ))) {
643600 zend_property_write_kind prop_write_kind = ZEND_PROPERTY_WRITE_OK ;
644601 if ((info -> flags & ZEND_ACC_READONLY ) && !Z_ISUNDEF_P (property_val )) {
645- prop_write_kind = zend_get_readonly_write_kind (property_val , info );
602+ prop_write_kind = zend_verify_readonly_slow (property_val , info );
646603 if (prop_write_kind == ZEND_PROPERTY_WRITE_FORBIDDEN ) {
647604 zend_readonly_property_modification_error (info );
648605 return ZEND_PROPERTY_WRITE_FORBIDDEN ;
0 commit comments