how can i access the second property or method in this statement
$this->test->hello();
In my __get() I can only figure out how to figure out what the test property is. I want to be also be able to capture the ‘hello’ method call. and do some dynamic things with it.
So in short if I type
$this->test->hello()
I want to echo each segment
echo $propert // test
echo $method //hello
The issue is that my test is being used to instantiate a new class object from an outside class. The method hello belongs to the test class object.
I want to capture the method within my __get().
How can i do this?
EDIT:
public function __get($name)
{
if ($name == 'system' || $name == 'sys') {
$_class = 'System_Helper';
} else {
foreach (get_object_vars($this) as $_property => $_value) {
if ($name == $_property)
$_class = $name;
}
}
$classname = '\\System\\' . ucfirst($_class);
$this->$_class = new $classname();
//$rClass = new \ReflectionClass($this->$_class);
$rClass = get_class_methods($this->$_class);
foreach($rClass as $k => $v)
echo $v."\n";
//print_r($rClass);
return $this->$_class;
It seems you are after some kind of proxy class, this might suit your needs.
Output:
Example:
http://ideone.com/dMna6
It could be easily extend for other magic methods like
__set,__callStatic,__isset,__invoke, etc.