Extender
Extender
The Class Extender Class
The Extender Class allows (or simulates) multiple class inheritance in PHP. It does this by loading instances of the extended class under the covers and transparently passing non-existent method calls on to 'child' classes (if the method exist). It will also work with member variables and honors the private, protected and public variable definitions.
Properties
children
private array $children
methods
private array $methods
properties
private array $properties
Methods
__call
public __call(string $method, array $args = []): void
This method call router will route the method call to the first child class that was found to have the requested method. If the method does not exist an \Exception is thrown.
Parameters
Parameter | Type | Description |
---|---|---|
$method | string | Then name of the method being called |
$args | array | An array of arguments from the method call |
__toString
public __toString(): string
Pass through method for converting the element to a string. If one of the child classes had a __tostring() method then this method is called on the first child that has it.
__get
public __get(string $property): mixed
Get a property from the instantiated class object for properties that do not exist. This will return the value of a property if it exists in a child class. This method honors the private, protected and public variable declarations.
Parameters
Parameter | Type | Description |
---|---|---|
$property | string | The property being requested |
__set
public __set(string $property, mixed $value): void
Set a property on the instantiated class object for properties that do not exist. This will set the value of a property if it exists in a child class. This method honors the private, protected and public variable declarations. If the child class variable is not meant to be accessible, either by not existing, or being set public, or being protected and the call originated outside the object, then the variable is created on the fly in the main object. This is the same as a normal object.
Parameters
Parameter | Type | Description |
---|---|---|
$property | string | The property being set |
$value | mixed | The value to set |
Test if the class extends another class.
public (string $class): bool
This implements the "instanceof" functionality of PHP and searches all the child classes to see if any of them extend the specified class.
Parameters
Parameter | Type | Description |
---|---|---|
$class | string | The name of the class to test |
extend
protected extend(): bool
Extend a class with a child class.
The arguments are as follows:
The name of the class to inherit from
... A list of arguments to pass on to the class constructor
Generated by Hazaar API Doc Generator