2017 © Pedro Peláez
 

library reflection

Reflection Extend Library.

image

wandu/reflection

Reflection Extend Library.

  • Sunday, April 16, 2017
  • by wan2land
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,822 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

Wandu Reflection

Latest Stable Version Latest Unstable Version Total Downloads License, (*1)

Build Status Code Coverage Scrutinizer Code Quality, (*2)

Reflection Extend Library., (*3)

Installation

$ composer require wandu/reflection

Documents

ReflectionCallable

It supports 6 types of callable object. (ref. Wani Blog, Callable), (*4)

  1. string of function's name.
  2. string of class and static method's name.
  3. array of class and static method's name.
  4. array of object and method's name.
  5. object of class that has __invoke method. (ref. Magic Method __invoke)
  6. object of Closure.

and two more., (*5)

  1. __call magic method.
  2. __callStatic magic method.
namespace Wandu\Reflection;

use ReflectionFunctionAbstract;
use Reflector;

class ReflectionCallable extends ReflectionFunctionAbstract implements Reflector {

    /* Method */
    public __construct( callable $callee )
    public mixed __invoke( ...$parameters )
    public string getCallableName()
    public boolean isMagicMethod()
    public int getReflectionType()
    public ReflectionFunctionAbstract getRawReflection()

    /* Inherited methods */
    final private void ReflectionFunctionAbstract::__clone ( void )
    public ReflectionClass ReflectionFunctionAbstract::getClosureScopeClass ( void )
    public object ReflectionFunctionAbstract::getClosureThis ( void )
    public string ReflectionFunctionAbstract::getDocComment ( void )
    public int ReflectionFunctionAbstract::getEndLine ( void )
    public ReflectionExtension ReflectionFunctionAbstract::getExtension ( void )
    public string ReflectionFunctionAbstract::getExtensionName ( void )
    public string ReflectionFunctionAbstract::getFileName ( void )
    public string ReflectionFunctionAbstract::getName ( void )
    public string ReflectionFunctionAbstract::getNamespaceName ( void )
    public int ReflectionFunctionAbstract::getNumberOfParameters ( void )
    public int ReflectionFunctionAbstract::getNumberOfRequiredParameters ( void )
    public array ReflectionFunctionAbstract::getParameters ( void )
    public ReflectionType ReflectionFunctionAbstract::getReturnType ( void )
    public string ReflectionFunctionAbstract::getShortName ( void )
    public int ReflectionFunctionAbstract::getStartLine ( void )
    public array ReflectionFunctionAbstract::getStaticVariables ( void )
    public bool ReflectionFunctionAbstract::hasReturnType ( void )
    public bool ReflectionFunctionAbstract::inNamespace ( void )
    public bool ReflectionFunctionAbstract::isClosure ( void )
    public bool ReflectionFunctionAbstract::isDeprecated ( void )
    public bool ReflectionFunctionAbstract::isGenerator ( void )
    public bool ReflectionFunctionAbstract::isInternal ( void )
    public bool ReflectionFunctionAbstract::isUserDefined ( void )
    public bool ReflectionFunctionAbstract::isVariadic ( void )
    public bool ReflectionFunctionAbstract::returnsReference ( void )
    abstract public void ReflectionFunctionAbstract::__toString ( void )
}

(ref. ReflectionFunctionAbstract Class), (*6)

Example.

use Wandu\Reflection\ReflectionCallable;

// 1. string of function's name.
$reflection = new ReflectionCallable('yourfunctionname'); // OK
$reflection = new ReflectionCallable('Your\OwnNamespace\yourfunctionname'); // with namespace also OK.

// 2. string of class and static method's name.
$reflection = new ReflectionCallable('Your\OwnNamespace\MyClass::callMyMethod'); // OK

// 3. array of class and static method's name.
$reflection = new ReflectionCallable(['Your\OwnNamespace\MyClass', 'callMyMethod']); // OK

// 4. array of object and method's name.
$reflection = new ReflectionCallable([new Your\OwnNamespace\MyClass(), 'callMyMethod']); // OK

// 5. object of class that has `__invoke` method.
$reflection = new ReflectionCallable(new Your\OwnNamespace\ClassWithInvoke()); // OK

// 6. object of `Closure`
$reflection = new ReflectionCallable(function ($param1, $param2) { /* do something */ });

$reflection->getNumberOfParameters(); // return 2

// 7. __call
$reflection = new ReflectionCallable([new Your\OwnNamespace\HasCallClass, 'anything']);

$reflection->getNumberOfParameters(); // always return 0
$reflection->getNumberOfRequiredParameters(); // always return 0
$reflection->getParameters(); // always return []
$reflection->getShortName(); // return 'anything'
$reflection->getName(); // return 'anything'

// 8. __callStatic
$reflection = new ReflectionCallable([Your\OwnNamespace\HasCallStaticClass::class, 'anything']);

$reflection->getNumberOfParameters(); // always return 0
$reflection->getNumberOfRequiredParameters(); // always return 0
$reflection->getParameters(); // always return []
$reflection->getShortName(); // return 'anything'
$reflection->getName(); // return 'anything'

The Versions

16/04 2017

dev-master

9999999-dev

Reflection Extend Library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Changwan Jun

reflection wandu callable reflection

16/04 2017

v0.3.0

0.3.0.0

Reflection Extend Library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Changwan Jun

reflection wandu callable reflection

31/08 2016

v0.2.0

0.2.0.0

Reflection Extend Library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Changwan Jun

reflection wandu callable reflection

25/04 2016

v0.1.0

0.1.0.0

Reflection Extend Library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Changwan Jun

reflection wandu callable reflection

29/07 2015

v0.0.1

0.0.1.0

Reflection Extend Library.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Changwan Jun

reflection wandu callable reflection