[php-src] Issue #9432: Dynamic property deprecation warning/readonly error not emitted when modifying through `new ArrayObject($targetObj);`
| From: | TysonAndre | Date: | Fri, 26 Aug 2022 13:25:14 +0000 |
| Subject: | [php-src] Issue #9432: Dynamic property deprecation warning/readonly error not emitted when modifying through `new ArrayObject($targetObj);` | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242315@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9432
Author: TysonAndre
### Description
The following code:
```php
<?php
class MyClass {}
$c = new MyClass();
$y = new ArrayObject($c);
$y['foo'] = 'bar'; // <-- should emit deprecation warning
$c->foo2 = 2;
var_export($c); echo "\n";
readonly class ReadOnly_ {}
$r = new ReadOnly_();
$z = new ArrayObject($r);
$z['foo'] = 'bar';
var_export($r);
```
Resulted in this output:
```
Deprecated: Creation of dynamic property MyClass::$foo2 is deprecated in
/usr/local/tyson/php-src/test.php on line 6
\MyClass::__set_state(array(
'foo' => 'bar',
'foo2' => 2,
))
\ReadOnly_::__set_state(array(
'foo' => 'bar',
))
```
But I expected this output instead:
```
Deprecated: Creation of dynamic property MyClass::$foo is deprecated in ...
Deprecated: Creation of dynamic property MyClass::$foo2 is deprecated in ... on line 6
\MyClass::__set_state(array(
'foo' => 'bar',
'foo2' => 2,
))
Uncaught Error: Cannot create dynamic property ReadOnly_::$foo in ...
```
Discovered while reviewing #9354
### PHP Version
8.2.0beta2
### Operating System
_No response_