From: spikeon at gmail dot com
Operating system: Mac
PHP version: 5.5.16
Package: Class/Object related
Bug Type: Bug
Bug description:__set() not firing when array is updated
Description:
------------
__set() doesn't fire if the variable is an array and a new value is
pushed to that array
---
From manual page: http://www.php.net/language.oop5.magic
---
Test script:
---------------
class Foo(){
private $info = [];
function __set($k, $v){
$this->info[$k] = $v;
}
function __get($k){
return $this->info[$k] ?: null;
}
}
$bar = new Foo();
$bar->foo = [];
$bar->foo[] = "foo1";
var_dump($bar->foo); // returns Array()
Expected result:
----------------
Upon update of the array, the array should be re-submitted to the
__set() method. If this would cause issues, perhaps a new magic method
could be created to handle changes of this nature, eg: __update() or
__change().
--
Edit bug report at https://bugs.php.net/bug.php?id=67899&edit=1
--