@@ -374,6 +374,12 @@ static ZEND_COLD zend_never_inline void zend_bad_property_name(void) /* {{{ */
374
374
}
375
375
/* }}} */
376
376
377
+ static ZEND_COLD zend_never_inline void zend_forbidden_dynamic_property (
378
+ zend_class_entry * ce , zend_string * member ) {
379
+ zend_throw_error (NULL , "Cannot create dynamic property %s::$%s" ,
380
+ ZSTR_VAL (ce -> name ), ZSTR_VAL (member ));
381
+ }
382
+
377
383
static zend_always_inline uintptr_t zend_get_property_offset (zend_class_entry * ce , zend_string * member , int silent , void * * cache_slot , zend_property_info * * info_ptr ) /* {{{ */
378
384
{
379
385
zval * zv ;
@@ -885,6 +891,11 @@ ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zva
885
891
886
892
ZVAL_COPY_VALUE (variable_ptr , value );
887
893
} else {
894
+ if (UNEXPECTED (zobj -> ce -> ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES )) {
895
+ zend_forbidden_dynamic_property (zobj -> ce , name );
896
+ variable_ptr = & EG (error_zval );
897
+ goto exit ;
898
+ }
888
899
if (!zobj -> properties ) {
889
900
rebuild_object_properties (zobj );
890
901
}
@@ -1048,6 +1059,10 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
1048
1059
}
1049
1060
if (EXPECTED (!zobj -> ce -> __get ) ||
1050
1061
UNEXPECTED ((* zend_get_property_guard (zobj , name )) & IN_GET )) {
1062
+ if (UNEXPECTED (zobj -> ce -> ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES )) {
1063
+ zend_forbidden_dynamic_property (zobj -> ce , name );
1064
+ return NULL ;
1065
+ }
1051
1066
if (UNEXPECTED (!zobj -> properties )) {
1052
1067
rebuild_object_properties (zobj );
1053
1068
}
0 commit comments