type
Table of Contents
Functions
- applies() : bool
- Finds whether an attribute has been applied to a given object, class, interface, or trait.
- uses() : bool
- Checks whether an object or class uses a given trait.
Functions
applies()
Finds whether an attribute has been applied to a given object, class, interface, or trait.
applies(object|class-string $object_or_class, class-string $attribute) : bool
Parameters
- $object_or_class : object|class-string
-
A class name or an object instance.
- $attribute : class-string
-
The attribute name.
Return values
bool —true
if the attribute has been applied to the given object or class.
false
otherwise.
uses()
Checks whether an object or class uses a given trait.
uses(object|string $object_or_class, string $trait[, bool $allow_string = true ]) : bool
Parameters
- $object_or_class : object|string
-
A class name or an object instance.
- $trait : string
-
The trait name.
- $allow_string : bool = true
-
If this parameter is set to
false
, a string class name as object_or_class is not allowed. This also prevents from calling autoloader if the class doesn't exist.
Return values
bool —This function returns true
if object_or_class, any of its traits,
any of its parents, or its parents' traits, use trait. false
otherwise.