I have a class TableData with two magic methods. One is the constructor and the other is the __call method.
I have realized the invoke with following code:
$class = new ReflectionClass('TableData');
$class->newInstanceArgs($parArray);
It work great. But now I want to use my magic method. So I call $class->getData()
, but it doesn't work. I get the error, that I called an undefined method.
I tried to use ReflectionMethod and invoke, but it doesn't work again.
Is there no way to cast the ReflectionClass Object to my TableData class?
Thanks for advice!
You can't call the method on the instance of ReflectionClass
. You have to call the method on the instance of your (reflected) original class.
$class = new ReflectionClass('TableData');
$instance = $class->newInstanceArgs($parArray);
$instance->getData();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With