[php-src] Issue #11229: ArrayObject - undocumented AllowDynamicProperties?

From: Date: Thu, 11 May 2023 08:25:08 +0000
Subject: [php-src] Issue #11229: ArrayObject - undocumented AllowDynamicProperties?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244429@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11229 Author: ondrejmirtes ### Description The following code: ```php <?php $obj = new \ArrayObject([ 'abc' => true, ], \ArrayObject::ARRAY_AS_PROPS); var_dump($obj->abc); ``` Resulted in this output: ``` bool(true) ``` But I expected this output instead: ``` Warning: Undefined property: ArrayObject::$abc ``` The [PHP RFC "Deprecate dynamic properties"](https://wiki.php.net/rfc/deprecate_dynamic_properties) says that only stdClass, classes with magic __get/__set methods, and classes marked as #[AllowDynamicProperties] are allowed to have dynamic properties. But ArrayObject is none of those: * https://www.php.net/manual/en/class.arrayobject.php * https://github.com/php/php-src/blob/5820528c9c25012ad763576c7120414eb12a05f0/ext/spl/spl_array.stub.php#L5 So what are the rules about dynamic properties? Are there any other cases where they are allowed that I'm unaware of? Please understand I'm asking from the point of a static analyser developer, to be able to describe these cases. I get it it's useful to have ArrayObject to allow them, but I need the rules to describe this behaviour. Thank you. ### PHP Version PHP 8.2 ### Operating System _No response_

« previous php.bugs (#244429) next »