OBS: I coded directly here, beacause my code is much more complex.
If I code:
class SuperFoo {
public function __get($name) {
return $this->$name;
}
public function __set($name, $value) {
$this->$name = $value;
}
}
class Foo extends SuperFoo {
private $bar = '';
}
$foo = new Foo();
$foo->bar = "Why it doesn't work?";
var_dump($foo);
Results in:
object(Foo) {
["bar":"Foo":private]=>
string(0) ''
}
And not in:
object(Foo) {
["bar":"Foo":private]=>
string(20) 'Why it doesn't work?'
}
Why this happen? I don't want to use an array to hold the attributes, because I need them declared as individual private members.
public functionin front of__getand__set.Fatal error: Cannot access private property Foo::$bar