[php-src] Issue #12694: Creation of dynamic property is deprecated !
| From: | Tak-Pesar | Date: | Thu, 16 Nov 2023 16:26:35 +0000 |
| Subject: | [php-src] Issue #12694: Creation of dynamic property is deprecated ! | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245818@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12694
Author: Tak-Pesar
### Description
The following code:
```php
<?php
final class Content {
protected array $data = array('sequence'=>1);
public function &__get(string $property) : mixed {
if(isset($this->data[$property]) === false):
$this->data[$property] = null;
endif;
return $this->data[$property];
}
public function __set(string $name,mixed $value) : void {
$this->data[$name] = $value;
}
}
$content = new Content();
$result = $content->sequence * 2 + 1;
$content->sequence += 1;
print $result;
```
Result:
```
3
```
But sometimes when the number of such requests increases, I receive the following warning :
```
Creation of dynamic property Content::$sequence is deprecated 18
```
### PHP Version
PHP 8.2.11
### Operating System
Linux