Open
Description
Description
The following code:
<?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