Overview

Namespaces

  • Pharborist
    • Constants
    • ControlStructures
    • Exceptions
    • Functions
    • Generators
    • Namespaces
    • Objects
    • Operators
    • Types
    • Variables

Classes

  • AnonymousFunctionNode
  • CallbackCallNode
  • CallNode
  • DefineNode
  • EmptyNode
  • EvalNode
  • FunctionCallNode
  • FunctionDeclarationNode
  • HaltCompilerNode
  • IssetNode
  • ListNode
  • ParameterNode
  • ParameterNodeCollection
  • UnsetNode

Interfaces

  • LexicalVariableNode

Traits

  • ArgumentTrait
  • FunctionTrait
  • ParameterTrait
  • Overview
  • Namespace
  • Class

Trait ParameterTrait

Trait for nodes that have parameters. For example, function declarations.

Direct Known Users

Pharborist\Functions\AnonymousFunctionNode, Pharborist\Functions\FunctionTrait
Namespace: Pharborist\Functions
Located at Functions/ParameterTrait.php
Methods summary
public Pharborist\CommaListNode
# getParameterList( )

Returns

Pharborist\CommaListNode
public Pharborist\Functions\ParameterNodeCollection
# getParameters( )

Returns

Pharborist\Functions\ParameterNodeCollection
public string[]
# getParameterNames( )

Returns

string[]
public
# prependParameter( Pharborist\Functions\ParameterNode $parameter )

Parameters

$parameter

Returns


$this
public
# appendParameter( Pharborist\Functions\ParameterNode|callable $parameter )

Appends a parameter.

Appends a parameter.

Parameters

$parameter

Either an existing parameter node, or a callable which will return the parameter to append. The callable will receive $this as its only argument.

Returns


$this

Throws

InvalidArgumentException
public
# insertParameter( Pharborist\Functions\ParameterNode $parameter, integer $index )

Insert parameter before parameter at index.

Insert parameter before parameter at index.

Parameters

$parameter
$index

Returns


$this

Throws

OutOfBoundsException
Index out of bounds.
public
# clearParameters( )

Remove all parameters.

Remove all parameters.

Returns


$this
public Pharborist\Functions\ParameterNode
# getParameter( mixed $key )

Gets a parameter by name or index.

Gets a parameter by name or index.

Parameters

$key

The parameter's name (without leading $) or position in the parameter list.

Returns

Pharborist\Functions\ParameterNode

Throws

InvalidArgumentException
if the key is not a string or integer.
public Pharborist\Functions\ParameterNode
# getParameterAtIndex( integer $index )

Gets a parameter by its position in the parameter list.

Gets a parameter by its position in the parameter list.

Parameters

$index

Returns

Pharborist\Functions\ParameterNode
public Pharborist\Functions\ParameterNode
# getParameterByName( string $name )

Gets a parameter by its name.

Gets a parameter by its name.

Parameters

$name
The parameter name with or without leading $.

Returns

Pharborist\Functions\ParameterNode

Throws

UnexpectedValueException
if the named parameter doesn't exist.
public boolean
# hasParameter( mixed $parameter, string $type = NULL )

Checks if the function/method has a certain parameter.

Checks if the function/method has a certain parameter.

Parameters

$parameter
Either the parameter name (with or without the $), or a ParameterNode.
$type
Optional type hint to check as well.

Returns

boolean

Throws

InvalidArgumentException

if $parameter is neither a string or a ParameterNode.

public boolean
# hasRequiredParameter( mixed $parameter, string $type = NULL )

Checks if the function/method has a specific required parameter.

Checks if the function/method has a specific required parameter.

Parameters

$parameter

Either the name of the parameter (with or without leading $), or a ParameterNode.

$type
Optional type hint to check.

Returns

boolean
public boolean
# hasOptionalParameter( mixed $parameter, string $type = NULL )

Checks if the function/method has a specific optional parameter.

Checks if the function/method has a specific optional parameter.

Parameters

$parameter

Either the name of the parameter (with or without leading $), or a ParameterNode.

$type
Optional type hint to check.

Returns

boolean
public boolean
# hasRequiredParameters( )

Returns

boolean
public Pharborist\NodeCollection
# getRequiredParameters( )

Returns

Pharborist\NodeCollection
public Pharborist\NodeCollection
# getOptionalParameters( )

Returns

Pharborist\NodeCollection
public boolean
# isVariadic( )

Returns if the final parameter is variadic (PHP 5.6+), as in: function foobaz($a, $b, ...$c)

Returns if the final parameter is variadic (PHP 5.6+), as in: function foobaz($a, $b, ...$c)

Returns

boolean
Pharborist API documentation generated by ApiGen