I have a method that looks something like this:
public function init(){
$this->app->classes = [
'route' => new Route(),
'routeParams' => new RouteParams()
];
return $this->app;
}
the classes property within App
looks like this
class App{
protected $classes = [];
}
I have another method that eventually gets called which has this line in it:
// Both $val and $item1 are strings
$this->app->classes['routeParams']->$val = $item1;
and when I run it, I get this error:
Indirect modification of overloaded property App::$classes has no effect
My RouteParams
class looks like this:
class RouteParams{
private $parameters = array();
public function __get($name){
if(isset($this->parameters[$name])){
return $this->parameters[$name];
}
return '';
}
public function __set($name, $value){
$this->parameters[$name] = $value;
}
}
What is causing my error and how can I fix it?