Skip to content

Dynamic property deprecation warning/readonly error not emitted when modifying through new ArrayObject($targetObj); #9432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TysonAndre opened this issue Aug 26, 2022 · 3 comments · May be fixed by #12037

Comments

@TysonAndre
Copy link
Contributor

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

@cmb69
Copy link
Member

cmb69 commented Aug 26, 2022

@jyxjjj
Copy link

jyxjjj commented Dec 7, 2022

Hello, What is the deprecation reason?
Which commit or pr or issue started this deprecation?

@cmb69
Copy link
Member

cmb69 commented Dec 7, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants