getConstants() returns an array of constants in that object.
getConstant() returns the value of any particular constant.
If you want a reference to the interfaces that a class implemented (if any), you
can use getInterfaces() function which, returns an array of interfaces as
ReflectionClass object.
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
Reflection and Unit Testing
[ 100 ]
The getModifiers() method returns the list of modifiers relevant to that
class. For example, it could be public, private, protected, abstract, static,
or final.
newInstance() function returns a new instance of that class and returns it
as a regular object (which is actually stdClas; stdClass is the base class of
every PHP object).
You want a reference to the parent class of any class? You can use
getParentClass() method to get that as a ReflectionClass object.
Another cool function of ReflectionClass() is that it can tell from which
extension a class has been originated. For example, ArrayObject class is
originated from SPL class. You have to use getExtensionName() function
for that.
Let's write some code now. We will see these functions in real life code. Here, I am
showing a fantastic example taken from the PHP Manual.
Pages:
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118