03/09
2017
Returns an anonymous callable function referencing the constructor of a class
, (*1)
A component of emeraldinspiration's library., (*2)
Returns an anonymous callable function referencing the constructor of a class, (*3)
PHP does not yet have a syntax for creating a callable for the constructor of a class. Some workarounds involve using ReflectionClass. (See: https://stackoverflow.com/q/24129450/6699286), (*4)
This class provides an alternate option. It creates an anonymous function that fulfills the callable need and runs the relevant constructor., (*5)
This project has no dependencies, so can simply be required with composer, (*6)
composer require emeraldinspirations/lib-createconstructcallable
<?php $Callable = ConstructCallableCreator::createConstructCallable( ExampleClass::class ); $NewClass = $Callable($Param1, $Param2); //Same result as new ExampleClass($Param1, $Param2)
The code in this project is licensed under MIT license., (*7)