[php-src] Issue #7786: PHP 8.2: unexpected deprecation for dynamic property set via magic method
| From: | jrfnl | Date: | Fri, 17 Dec 2021 17:09:01 +0000 |
| Subject: | [php-src] Issue #7786: PHP 8.2: unexpected deprecation for dynamic property set via magic method | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238463@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7786
Author: jrfnl
### Description
The following code:
```php
<?php
class Foo {
public function __set( $name, $value ) {
$this->$name = $value;
}
}
$obj = new Foo();
$obj->test = 'test';
```
Resulted in this output:
```
Deprecated: Creation of dynamic property Foo::$test is deprecated in /in/Ds0gN on line 5
```
https://3v4l.org/Ds0gN/rfc#vgit.master
But I expected this output instead:
```
No error
```
I realize that this is an "unconventional" interpretation of how magic methods should be
implemented, but at the same time, the RFC explicitly excluded dynamic properties being set via
magic methods from the deprecation, so I'd really like to invite some discussion on this.
### PHP Version
8.2/nightly
### Operating System
_No response_