-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
Description
Description
The following code ( This should never happen when I'm using magic methods, but unfortunately it does happen sometimes ):
<?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