Indirect modification of overloaded property %s::$%s has no effect¶
Description¶
The variable $object is an object. Since it implements the __get magic method, any property is available.
While the syntax makes $object->something looks like a actual property and an array, not all operations are available. It is possible to get any property’s value, or to give it a new value; but it is not possible to use the append operator : this is not supported by the magic method.
There are different variations of that situation : for example, an increment or decrement on the value on a property is not possible either.
There is no call that will relay to the magic method that this property is being appended or incremented.
Example¶
<?php
class OneObject {
function __get($var) { }
}
$object = new OneObject;
$object->something[] = 'bar';
?>
Literal Examples¶
Indirect modification of overloaded property OneObject::$something has no effect
Solutions¶
Use an actual data container to represent a property.