A set of utility function for use with PHP Reflection.
The following functions are supplied
All functions live in the BitwiseOperators\Reflection namespace.
Arguments:
- class:
object|string
The following functions check if an attribute is set on the supplied class, function, method or property.
For all functions, the attribute can be supplied as a class-string or as a ReflectionAttribute object for the desired attribute.
Attributes are checked in instance-mode, so descendant implementations of the supplied attribute also return true
If no attribute class is specified, the functions return true when the subject has any attributes.
Arguments:
- class:
object|string, - attribute:
null|string|ReflectionAttribute
Checks the supplied class for attributes $attribute.
The class can be supplied as an object, a string, or as a ReflectionClass containing the subject.
Arguments:
- function:
ReflectionFunctionAbstract|string, - attribute:
null|string|ReflectionAttribute
Checks the supplied function for attributes.
The function can be supplied as a string or as a ReflectionFunctionAbstract containing the subject.
Make sure the function is fully namespaced if applicable.
This function has two possible signatures:
Arguments:
- class:
object|string - method:
ReflectionMethod|string - attribute:
null|string|ReflectionAttribute
The method can be supplied as a combination of class and method-name, where the class arguments follow the same requirements as for
the class_has_attributes function. The method can be either a string or a ReflectionMethod containing the method.
When using a ReflectionMethod object, the class argument can be omitted completely:
Arguments:
- method:
ReflectionMethod - attribute:
null|string|ReflectionAttribute
This function has two possible signatures:
Arguments:
- class:
object|string - property:
ReflectionProperty|string - attribute:
null|string|ReflectionAttribute
The property can be supplied as a combination of class and property-name, where the class arguments follow the same requirements as for
the class_has_attributes function. The property can be either a string or a ReflectionProperty containing the method.
When using a ReflectionProperty object, the class argument can be omitted completely:
Arguments:
- property:
ReflectionProperty - attribute:
null|string|ReflectionAttribute