XRL  3.0.1
Simple XML-RPC Library (both client and server)
fpoirotte\XRL\CallableObject Class Reference

Class used to represent anything that is callable. More...

+ Inheritance diagram for fpoirotte\XRL\CallableObject:

Public Member Functions

 __construct ($callable)
 
 __invoke ()
 
 __toString ()
 
 getCallable ()
 
 getReflector ()
 
 getRepresentation ()
 
 invokeArgs (array &$args)
 

Protected Attributes

 $callableObj
 Inner callable object, as used by PHP.
 
 $representation
 Human representation of the inner callable.
 

Static Private Attributes

static $patched
 Work-around for __invoke() with references in PHP 5.6.0+.
 

Detailed Description

Class used to represent anything that is callable.

This class can represent a wild range of callable items supported by PHP (functions, lambdas, methods, closures, etc.).

Authors
François Poirotte click.nosp@m.y@er.nosp@m.ebot..nosp@m.net

Definition at line 23 of file CallableObject.php.

Constructor & Destructor Documentation

fpoirotte\XRL\CallableObject::__construct (   $callable)

Constructs a new callable object, abstracting differences between the different constructs PHP supports.

Parameters
mixed$callableA callable item. It must be compatible with the PHP callback pseudo-type.
Exceptions
InvalidArgumentExceptionThe given item is not compatible with the PHP callback pseudo-type.
See also
More information on the callback pseudo-type can be found here: http://php.net/language.pseudo-types.php#language.types.callback

Definition at line 51 of file CallableObject.php.

References fpoirotte\XRL\CallableObject\$representation.

Member Function Documentation

fpoirotte\XRL\CallableObject::__invoke ( )

Implements fpoirotte\XRL\CallableInterface.

Definition at line 106 of file CallableObject.php.

fpoirotte\XRL\CallableObject::__toString ( )

Alias for fpoirotte::XRL::CallableInterface::getRepresentation().

Return values
stringHuman representation of this callable.
See also
fpoirotte::XRL::CallableInterface::getRepresentation()

Implements fpoirotte\XRL\CallableInterface.

Definition at line 112 of file CallableObject.php.

References fpoirotte\XRL\CallableObject\$representation.

fpoirotte\XRL\CallableObject::getCallable ( )

Returns the callable object in its raw form (as used by PHP).

Return values
stringThe name of the function this callable represents, which can be either a core function, a user-defined function, or the result of a call to create_function().
arrayAn array whose contents matches the definition of a PHP callback, that is:
  • The first element refers to either an object, a class name or one of the reserved keywords (self, parent, static, etc.).
  • The second element is the name of a method from that object/class.
objectEither a Closure object or an instance of a class that implements the __invoke() magic method.

Implements fpoirotte\XRL\CallableInterface.

Definition at line 84 of file CallableObject.php.

References fpoirotte\XRL\CallableObject\$callableObj.

fpoirotte\XRL\CallableObject::getReflector ( )

Get a reflection objets for the function/method/object represented by this callable.

Return values
ReflectorReflection object for this callable's inner PHP callback.

Implements fpoirotte\XRL\CallableInterface.

Definition at line 118 of file CallableObject.php.

References fpoirotte\XRL\CallableObject\$callableObj.

fpoirotte\XRL\CallableObject::getRepresentation ( )

Returns a human representation of this callable. For (anonymous) functions, this is a string containing the name of that function. For methods and classes that implement the __invoke() magic method (including Closures), this is a string of the form "ClassName::methodname".

Return values
stringHuman representation of this callable.

Implements fpoirotte\XRL\CallableInterface.

Definition at line 90 of file CallableObject.php.

References fpoirotte\XRL\CallableObject\$representation.

fpoirotte\XRL\CallableObject::invokeArgs ( array &  $args)

Invokes the callable object represented by this instance, using the given array as a list of arguments.

Parameters
array$argsAn array whose values will become the arguments for the inner callable.
Return values
mixedValue returned by the inner callable.

Implements fpoirotte\XRL\CallableInterface.

Definition at line 96 of file CallableObject.php.


The documentation for this class was generated from the following file: