ExtendableTrait
trait ExtendableTrait
Extendable Trait Allows for "Private traits"
Adapted from the October ExtendableTrait
Properties
protected array | $extensionData | ||
static protected array | $extendableCallbacks | ||
static protected array | $extendableStaticMethods | ||
static protected bool | $extendableGuardProperties | ||
static protected ClassLoader | $extendableClassLoader |
Methods
Constructor.
Helper method for ::extend() static method
Clear the list of extended classes so they will be re-extended.
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
Dynamically extend a class with a specified behavior
Extracts the available methods from a behavior and adds it to the list of callable methods.
Programmatically adds a method to the extendable class
Programatically adds a property to the extendable class
Check if extendable class is extended with a behavior object
Returns a behavior object from an extendable class, example:
Short hand for getClassExtension() method, except takes the short extension name, example:
Checks if a method exists, extension equivalent of method_exists()
Get a list of class methods, extension equivalent of get_class_methods()
Returns all dynamic properties and their values
Checks if a property exists, extension equivalent of property_exists()
Checks if a property is accessible, property equivalent of is_callabe()
Magic method for __get()
Magic method for __set()
Magic method for __call()
Magic method for __callStatic()
Gets the class loader
Details
at line 55
extendableConstruct()
Constructor.
at line 103
static void
extendableExtendCallback(callable $callback)
Helper method for ::extend() static method
at line 120
static void
clearExtendedClasses()
Clear the list of extended classes so they will be re-extended.
at line 131
protected string
extensionNormalizeClassName(string $name)
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
at line 149
void|ExtendableTrait
extendClassWith(string $extensionName)
Dynamically extend a class with a specified behavior
at line 178
protected void
extensionExtractMethods(string $extensionName, object $extensionObject)
Extracts the available methods from a behavior and adds it to the list of callable methods.
at line 206
addDynamicMethod(string $dynamicName, callable $method, string $extension = null)
Programmatically adds a method to the extendable class
at line 225
addDynamicProperty(string $dynamicName, string $value = null)
Programatically adds a property to the extendable class
at line 249
bool
isClassExtendedWith(string $name)
Check if extendable class is extended with a behavior object
at line 265
mixed
getClassExtension(string $name)
Returns a behavior object from an extendable class, example:
$this->getClassExtension('Admin.Actions.FormController')
at line 280
mixed
asExtension(string $shortName)
Short hand for getClassExtension() method, except takes the short extension name, example:
$this->asExtension('FormController')
at line 301
bool
methodExists(string $name)
Checks if a method exists, extension equivalent of method_exists()
at line 313
array
getClassMethods()
Get a list of class methods, extension equivalent of get_class_methods()
at line 326
array
getDynamicProperties()
Returns all dynamic properties and their values
at line 344
bool
propertyExists(string $name)
Checks if a property exists, extension equivalent of property_exists()
at line 370
protected bool
extendableIsAccessible(mixed $class, string $propertyName)
Checks if a property is accessible, property equivalent of is_callabe()
at line 385
string
extendableGet(string $name)
Magic method for __get()
at line 410
string
extendableSet(string $name, string $value)
Magic method for __set()
at line 444
mixed
extendableCall(string $name, array $params = null)
Magic method for __call()
at line 483
static mixed
extendableCallStatic(string $name, array $params = null)
Magic method for __callStatic()
at line 552
protected ClassLoader|null
extensionGetClassLoader()
Gets the class loader