@@ -261,6 +261,12 @@ static ZEND_COLD zend_never_inline void zend_bad_property_name(void) /* {{{ */
261
261
}
262
262
/* }}} */
263
263
264
+ static ZEND_COLD zend_never_inline void zend_forbidden_dynamic_property (
265
+ zend_class_entry * ce , zend_string * member ) {
266
+ zend_throw_error (NULL , "Cannot create dynamic property %s::$%s" ,
267
+ ZSTR_VAL (ce -> name ), ZSTR_VAL (member ));
268
+ }
269
+
264
270
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 ) /* {{{ */
265
271
{
266
272
zval * zv ;
@@ -772,6 +778,11 @@ ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zva
772
778
773
779
ZVAL_COPY_VALUE (variable_ptr , value );
774
780
} else {
781
+ if (UNEXPECTED (zobj -> ce -> ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES )) {
782
+ zend_forbidden_dynamic_property (zobj -> ce , name );
783
+ variable_ptr = & EG (error_zval );
784
+ goto exit ;
785
+ }
775
786
if (!zobj -> properties ) {
776
787
rebuild_object_properties (zobj );
777
788
}
@@ -935,6 +946,10 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
935
946
}
936
947
if (EXPECTED (!zobj -> ce -> __get ) ||
937
948
UNEXPECTED ((* zend_get_property_guard (zobj , name )) & IN_GET )) {
949
+ if (UNEXPECTED (zobj -> ce -> ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES )) {
950
+ zend_forbidden_dynamic_property (zobj -> ce , name );
951
+ return NULL ;
952
+ }
938
953
if (UNEXPECTED (!zobj -> properties )) {
939
954
rebuild_object_properties (zobj );
940
955
}
0 commit comments