## PassedParameters

PassedParameters.php : 25

Utility functions to retrieve information about parameters passed to function calls, array declarations, isset and unset constructs.

##### Tags

since
  1.0.0

### Table of Contents

getParameter() : array|false
  Get information on a specific parameter passed.
getParameterCount() : int
  Count the number of parameters which have been passed.
getParameters() : array
  Get information on all parameters passed.
hasParameters() : bool
  Checks if any parameters have been passed.

### Methods

#### getParameter()

PassedParameters.php : 303

Get information on a specific parameter passed.

`public static getParameter(File $phpcsFile, int $stackPtr, int $paramOffset) : array|false`

See \PHPCSUtils\Utils\PassedParameters::hasParameters() for information on the supported constructs.

##### Parameters

$phpcsFile : File

  The file where this token was found.

$stackPtr : int

  The position of the `T_STRING`, `T_VARIABLE`, `T_ARRAY`, `T_OPEN_SHORT_ARRAY`, `T_ISSET` or `T_UNSET` token.

$paramOffset : int

  The 1-based index position of the parameter to retrieve.

##### Tags

since
  1.0.0
throws
  RuntimeException

  If the token passed is not one of the accepted types or doesn't exist.

##### Return values

array|false —

Array with information on the parameter/array item at the specified offset. Or `FALSE` if the specified parameter/array item is not found. The format of the return value is:

    array(
      'start' => int,    // The stack pointer to the first token in the parameter/array item.
      'end'   => int,    // The stack pointer to the last token in the parameter/array item.
      'raw'   => string, // A string with the contents of all tokens between `start` and `end`.
      'clean' => string, // Same as `raw`, but all comment tokens have been stripped out.
    )

#### getParameterCount()

PassedParameters.php : 330

Count the number of parameters which have been passed.

`public static getParameterCount(File $phpcsFile, int $stackPtr) : int`

See \PHPCSUtils\Utils\PassedParameters::hasParameters() for information on the supported constructs.

##### Parameters

$phpcsFile : File

  The file where this token was found.

$stackPtr : int

  The position of the `T_STRING`, `T_VARIABLE`, `T_ARRAY`, `T_OPEN_SHORT_ARRAY`, `T_ISSET` or `T_UNSET` token.

##### Tags

since
  1.0.0
throws
  RuntimeException

  If the token passed is not one of the accepted types or doesn't exist.

##### Return values

int —

#### getParameters()

PassedParameters.php : 181

Get information on all parameters passed.

`public static getParameters(File $phpcsFile, int $stackPtr) : array`

See \PHPCSUtils\Utils\PassedParameters::hasParameters() for information on the supported constructs.

##### Parameters

$phpcsFile : File

  The file where this token was found.

$stackPtr : int

  The position of the `T_STRING`, `T_VARIABLE`, `T_ARRAY`, `T_OPEN_SHORT_ARRAY`, `T_ISSET`, or `T_UNSET` token.

##### Tags

since
  1.0.0
throws
  RuntimeException

  If the token passed is not one of the accepted types or doesn't exist.

##### Return values

array —

A multi-dimentional array information on each parameter/array item. The information gathered about each parameter/array item is in the following format:

    1 => array(
      'start' => int,    // The stack pointer to the first token in the parameter/array item.
      'end'   => int,    // The stack pointer to the last token in the parameter/array item.
      'raw'   => string, // A string with the contents of all tokens between `start` and `end`.
      'clean' => string, // Same as `raw`, but all comment tokens have been stripped out.
    )

Note: The array starts at index 1. If no parameters/array items are found, an empty array will be returned.

#### hasParameters()

PassedParameters.php : 88

Checks if any parameters have been passed.

`public static hasParameters(File $phpcsFile, int $stackPtr) : bool`

- If passed a `T_STRING` or `T_VARIABLE` stack pointer, it will treat it as a function call. If a `T_STRING` or `T_VARIABLE` which is not a function call is passed, the behaviour is undetermined.
- If passed a `T_SELF` or `T_STATIC` stack pointer, it will accept it as a function call when used like `new self()`.
- If passed a `T_ARRAY` or `T_OPEN_SHORT_ARRAY` stack pointer, it will detect whether the array has values or is empty.
- If passed a `T_ISSET` or `T_UNSET` stack pointer, it will detect whether those language constructs have "parameters".

##### Parameters

$phpcsFile : File

  The file where this token was found.

$stackPtr : int

  The position of the `T_STRING`, `T_VARIABLE`, `T_ARRAY`, `T_OPEN_SHORT_ARRAY`, `T_ISSET`, or `T_UNSET` token.

##### Tags

since
  1.0.0
throws
  RuntimeException

  If the token passed is not one of the accepted types or doesn't exist.

##### Return values

bool —

## Search results