2017 © Pedro Peláez
 

library lib-createconstructcallable

Returns an anonymous callable function referencing the constructor of a class

image

emeraldinspirations/lib-createconstructcallable

Returns an anonymous callable function referencing the constructor of a class

  • Sunday, September 3, 2017
  • by emeraldinspirations
  • Repository
  • 0 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

emeraldinspirations logo, (*1)

lib-createconstructcallable

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)

Installing / Getting started

This project has no dependencies, so can simply be required with composer, (*6)

composer require emeraldinspirations/lib-createconstructcallable

How to use

<?php

$Callable = ConstructCallableCreator::createConstructCallable(
    ExampleClass::class
);

$NewClass = $Callable($Param1, $Param2);
//Same result as new ExampleClass($Param1, $Param2)

Licensing

The code in this project is licensed under MIT license., (*7)

The Versions

03/09 2017

dev-master

9999999-dev

Returns an anonymous callable function referencing the constructor of a class

  Sources   Download

MIT

by Matthew "Juniper" Barlett

03/09 2017

1.0.0

1.0.0.0

Returns an anonymous callable function referencing the constructor of a class

  Sources   Download

MIT

by Matthew "Juniper" Barlett