I wrote a class like this :
class config {
private $conf;
public function __call( $confName, $args ){
if ( 0 == count($args) && isset($this->conf[$confName]) ){
return $this->conf[$confName];
}
else {
$this->conf[$confName] = $args[0];
return $this;
}
}
}
and $conf = new config();
but I wanna get the suggest list when I input $conf->,
is there any ideal or it's impossible to do that ?
class config {
private $conf;
public function none_existent_method1(){
// forward the call to __call(__FUNCTION__, ...)
return call_user_func(array($this, '__call'),
__FUNCTION__, func_get_args());
}
public function none_existent_method2(){
// forward the call to __call(__FUNCTION__, ...)
return call_user_func(array($this, '__call'),
__FUNCTION__, func_get_args());
}
public function __call( $func, $args ){
if ( 0 == count($args) && isset($this->conf[$func]) ){
return $this->conf[$func];
}
else {
$this->conf[$func] = $args[0];
return $this;
}
}
}
Just add the methods and forward them to __call
yourself.
There are other ways but all require you declare the functions.