If I use magic methods. While using reflection API, I can't investigate class properties.. Why is it so?
EDIT
What is Reflection API? pls do not refer me php.net i didnt understood that.. guide me in your words plsss
If I use magic methods. While using reflection API, I can't investigate class properties.. Why is it so?
EDIT
What is Reflection API? pls do not refer me php.net i didnt understood that.. guide me in your words plsss
Using magic methods to access properties, those properties will generally not be present in the class' definition.
Your class' definition will generally look like this :
class MyClass {
private $data;
public function __get($name) {
return $this->data[$name];
}
public function __set($name, $value) {
$this->data[$name] = $value;
}
}
As there is no real properties -- there is on only a $data
array, which will be used by the magic methods __get
an __set
as a big data-store -- those cannot be seen by the Reflection API.
That's one of the problems caused by using magic methods : they are used to access properties (or methods, with __call
) which are not there -- and the Reflection API can only see what's there.