-
-
Notifications
You must be signed in to change notification settings - Fork 0
Wiki ClsObj
abstract class \FireHub\Core\Support\LowLevel\ClsObj()
Important
This is an abstract class that cannot be instantiated directly.
Class allows you to obtain information about classes and objects.
This class was created by Danijel Galić <danijel.galic@outlook.com>
Copyright: 2024 FireHub Web Application Framework
License: <https://opensource.org/licenses/OSL-3.0> OSL Open Source License version 3
Version: GIT: $Id$ Blob checksum.
Fully Qualified Class Name: \FireHub\Core\Support\LowLevel\ClsObj
Source code: view source code
Blame: view blame
History: view history
Type | Name | Title |
---|---|---|
public static | methodExist | ### Checks if the class method exists |
public static | propertyExist | ### Checks if the object or class has a property |
public static | ofClass | ### Checks whether the object or class is of a given type or subtype |
public static | subClassOf | ### Checks if class has this class as one of its parents or implements it |
public static | methods | ### Gets the class or object methods names |
public static | parentClass | ### Retrieves the parent class name for an object or class |
public static | parents | ### Return the parent classes of the given class |
public static | implements | ### Return the interfaces which are implemented by the given class or interface |
public static | uses | ### Return the traits used by the given class |
public static ClsObj::methodExist(string|object $object_or_class, string $method):bool
Note
Using this function will use any registered autoloaders if the class is not already known.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
An object instance or a class name. - string $method -
non-empty-string
The method name.
- bool - True if the method given by method has been defined for the given object_or_class, false otherwise.
final public static ClsObj::propertyExist(string|object $object_or_class, string $property):bool
Important
This method is marked as final.
Note
As opposed with isset(), ClsObj#propertyExist() returns true even if the property has the value null.> [!NOTE] This method cannot detect properties that are magically accessible using the __get magic method.> [!NOTE] Using this function will use any registered autoloaders if the class is not already known.
This method checks if the given property exists in the specified class.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
The class name or an object of the class to test for. - string $property -
non-empty-string
The name of the property.
- \Error - If there was an error trying to get property.
- bool - True if the property exists, false if it doesn't exist.
public static ClsObj::ofClass(string|object $object_or_class, string $class, bool $autoload = true):bool
Checks if the given $object_or_class is of this object type or has this object type as one of its supertypes.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
A class name or an object instance. - string $class - The class or interface name.
- bool $autoload = true - _[optional] Whether to allow this function to load the class automatically through the _autoload magic method.
- bool - True if the object is of this object type or has this object type as one of its supertypes, false otherwise.
public static ClsObj::subClassOf(string|object $object_or_class, string $class, bool $autoload = true):bool
Checks if the given object_or_class has the class $class as one of its parents or implements it.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
The tested class. No error is generated if the class does not exist. - string $class - The class or interface name.
- bool $autoload = true - _[optional] Whether to allow this function to load the class automatically through the _autoload magic method.
- bool - True if the object is of this object or lass type or has this object type as one of its supertypes, false otherwise.
final public static ClsObj::methods(string|object $object_or_class):array
Important
This method is marked as final.
Note
The result depends on the current scope.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
The class name or an object instance.
- \TypeError - If $object_or_class is not an object or a valid class name.
- array -
array
Returns an array of method names defined for the class.
final public static ClsObj::parentClass(string|object $object_or_class):string|false
Important
This method is marked as final.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
The tested object or class name. This parameter is optional if called from the object's method.
- string or false -
class-string|false
The name of the parent class for the class that $object_or_class is an instance or the name, or false if object_or_class doesn't have a parent.
final public static ClsObj::parents(string|object $object_or_class, bool $autoload = true):array
Important
This method is marked as final.
This function returns an array with the name of the parent classes of the given object_or_class.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
An object (class instance) or a string (class or interface name). - bool $autoload = true - _[optional] Whether to allow this function to load the class automatically through the _autoload magic method.
- \Error - If $object_or_class does not exist and could not be loaded.
- array -
array<string, class-string>
An array on success.
final public static ClsObj::implements(string|object $object_or_class, bool $autoload = true):array
Important
This method is marked as final.
This function returns an array with the names of the interfaces that the given object_or_class and its parents implement.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
An object (class instance) or a string (class or interface name). - bool $autoload = true - _[optional] Whether to allow this function to load the class automatically through the _autoload magic method.
- \Error - If $object_or_class does not exist and could not be loaded.
- array -
array<string, class-string>
An array.
final public static ClsObj::uses(string|object $object_or_class, bool $autoload = true):array
Important
This method is marked as final.
This function returns an array with the names of the traits that the given object_or_class uses. This does, however, not include any traits used by a parent class.
Source code: view source code
Blame: view blame
- string or object $object_or_class -
class-string|object
An object (class instance) or a string (class or interface name). - bool $autoload = true - _[optional] Whether to allow this function to load the class automatically through the _autoload magic method.
- \Error - If $object_or_class does not exist and could not be loaded.
- array -
array<string, class-string>
An array.
Build with phpDocumentor using template FireHub phpDocumentor Wiki Template.