The ezcReflectionParameter class retrieves information about a function's or method's parameters and their types.
Extends the ReflectionParameter class to provide type information using PHPDoc annotations.
Source for this file: /Reflection/src/parameter.php
ReflectionParameter | --ezcReflectionParameter
Version: | //autogen// |
protected ReflectionParameter |
$parameter
= null
ReflectionParameter instance if one was provided to the constructor |
protected integer|string|ReflectionParameter |
$reflectionSource
|
protected ezcReflectionType |
$type
Type of the parameter |
From ReflectionParameter (Internal Class) | |
---|---|
public |
$name
|
public static mixed |
export(
$function
, $parameter
, [ $return
= false] )
Exports a reflection object. |
public ezcReflectionParameter |
__construct(
$functionOrMethod
, $parameterPositionNameOrSource
, [ $type
= null] , $parameter
)
Constructor |
public boolean |
allowsNull(
)
Returns whether NULL is allowed as this parameters's value |
protected mixed |
forwardCallToReflectionSource(
$method
, [ $arguments
= array()] )
Forwards a method invocation to either the reflection source passed to the constructor of this class when creating an instance or to the parent class. |
public ezcReflectionClass|NULL |
getClass(
)
Returns reflection object identified by type hinting or NULL if there is no hint |
public ezcReflectionClass |
getDeclaringClass(
)
Returns in which class this parameter is defined (not the type hint of the parameter) |
public ezcReflectionFunction|ezcReflectionMethod |
getDeclaringFunction(
)
Returns the function or method declaring this parameter |
public mixed |
getDefaultValue(
)
Returns the default value of this parameter or throws an exception |
public string |
getName(
)
Returns this parameters's name |
public integer |
getPosition(
)
Returns whether this parameter is an optional parameter |
public ezcReflectionType |
getType(
)
Returns the type of this parameter in form of an ezcReflectionType |
public boolean |
isArray(
)
Returns whether parameter MUST be an array |
public boolean |
isDefaultValueAvailable(
)
Returns whether the default value of this parameter is available |
public boolean |
isOptional(
)
Returns whether this parameter is an optional parameter |
public boolean |
isPassedByReference(
)
Returns whether this parameters is passed to by reference |
public mixed |
__call(
$method
, $arguments
)
Use overloading to call additional methods of the ReflectionParameter instance given to the constructor. |
public string |
__toString(
)
Returns a string representation |
From ReflectionParameter (Internal Class) | |
---|---|
public ReflectionParameter |
constructor __construct ( $function, $parameter )
|
public void |
allowsNull ( )
|
public void |
export ( $function, $parameter, [$return = ] )
|
public void |
getClass ( )
|
public void |
getDeclaringClass ( )
|
public void |
getDeclaringFunction ( )
|
public void |
getDefaultValue ( )
|
public void |
getName ( )
|
public void |
getPosition ( )
|
public void |
isArray ( )
|
public void |
isDefaultValueAvailable ( )
|
public void |
isOptional ( )
|
public void |
isPassedByReference ( )
|
public void |
__clone ( )
|
public void |
__toString ( )
|
Exports a reflection object.
Returns the output if TRUE is specified for $return, printing it otherwise. This is purely a wrapper method, which calls the corresponding method of the parent class.
Name | Type | Description |
---|---|---|
$function |
mixed | Function or Method |
$parameter |
mixed | Parameter |
$return |
boolean | Whether to return (TRUE) or print (FALSE) the output |
Method | Description |
---|---|
ReflectionParameter::export ( $function, $parameter, [$return = ] ) |
Constructor
If called with a ReflectionParameter instance as second argument the, first argument should be a string identifying the type of the parameter.
Name | Type | Description |
---|---|---|
$functionOrMethod |
string|array |
The function, method or type of the parameter given as function name, array($classname, $method), or array($object, $method) |
$parameter |
integer|string|ReflectionParameter | Position (starting at 0), name, or ReflectionParameter instance of the parameter to introspect. |
$type |
string | Type of the parameter given in form of the type name. |
$parameterPositionNameOrSource |
Type | Description |
---|---|
ReflectionException |
in case the given method or function does not exist. |
Method | Description |
---|---|
ReflectionParameter::constructor __construct ( $function, $parameter ) |
Returns whether NULL is allowed as this parameters's value
Method | Description |
---|---|
ReflectionParameter::allowsNull ( ) |
Forwards a method invocation to either the reflection source passed to the constructor of this class when creating an instance or to the parent class.
This method is part of the dependency injection mechanism and serves as a helper for implementing wrapper methods without code duplication.
Name | Type | Description |
---|---|---|
$method |
string | Name of the method to be invoked |
$arguments |
mixed[] | Arguments to be passed to the method |
Returns reflection object identified by type hinting or NULL if there is no hint
This method does not rely on type annotations. That gives users the freedom to decide on whether they want to trust the type annotations, i.e., by calling getType(), or only PHP's type hinting, which is the sole data source for this method.
Type | Description |
---|---|
ReflectionException |
if a parameter uses 'self' or 'parent' as type hint, but function is not a class member, if a parameter uses 'parent' as type hint, although class does not have a parent, or if the class does not exist |
Method | Description |
---|---|
ReflectionParameter::getClass ( ) |
Returns in which class this parameter is defined (not the type hint of the parameter)
Method | Description |
---|---|
ReflectionParameter::getDeclaringClass ( ) |
Returns the function or method declaring this parameter
Method | Description |
---|---|
ReflectionParameter::getDeclaringFunction ( ) |
Returns the default value of this parameter or throws an exception
Method | Description |
---|---|
ReflectionParameter::getDefaultValue ( ) |
Returns this parameters's name
Method | Description |
---|---|
ReflectionParameter::getName ( ) |
Returns whether this parameter is an optional parameter
Method | Description |
---|---|
ReflectionParameter::getPosition ( ) |
Returns the type of this parameter in form of an ezcReflectionType
A valid type hint for the parameter will be preferred over a type annotation.
Type | Description |
---|---|
ReflectionException |
if a parameter uses 'self' or 'parent' as type hint, but function is not a class member, if a parameter uses 'parent' as type hint, although class does not have a parent, or if the class does not exist |
Returns whether parameter MUST be an array
Method | Description |
---|---|
ReflectionParameter::isArray ( ) |
Returns whether the default value of this parameter is available
Method | Description |
---|---|
ReflectionParameter::isDefaultValueAvailable ( ) |
Returns whether this parameter is an optional parameter
Method | Description |
---|---|
ReflectionParameter::isOptional ( ) |
Returns whether this parameters is passed to by reference
Method | Description |
---|---|
ReflectionParameter::isPassedByReference ( ) |
Use overloading to call additional methods of the ReflectionParameter instance given to the constructor.
Name | Type | Description |
---|---|---|
$method |
string | Method to be called |
$arguments |
array | Arguments that were passed |
Returns a string representation
Method | Description |
---|---|
ReflectionParameter::__toString ( ) |