PHP Class BetterReflection\Reflection\ReflectionParameter

Inheritance: implements Reflector
Afficher le fichier Open project: roave/better-reflection Class Usage Examples

Méthodes publiques

Méthode Description
__clone ( )
__toString ( ) : string Return string representation of this parameter.
allowsNull ( ) : boolean Does this method allow null for a parameter?
canBePassedByValue ( ) : boolean
createFromClassInstanceAndMethod ( object $instance, string $methodName, string $parameterName ) : ReflectionParameter Create a reflection of a parameter using an instance
createFromClassNameAndMethod ( string $className, string $methodName, string $parameterName ) : ReflectionParameter Create a reflection of a parameter using a class name
createFromNode ( BetterReflection\Reflector\Reflector $reflector, Param $node, ReflectionFunctionAbstract $function, integer $parameterIndex ) : ReflectionParameter
createFromSpec ( string[] | string | Closure $spec, string $parameterName ) : ReflectionParameter Create the parameter from the given spec. Possible $spec parameters are:
export ( )
getClass ( ) : ReflectionClass | null Gets a ReflectionClass for the type hint (returns null if not a class)
getDeclaringClass ( ) : ReflectionClass | null Get the class from the method that this parameter belongs to, if it exists.
getDeclaringFunction ( ) : ReflectionFunctionAbstract Get the function (or method) that declared this parameter.
getDefaultValue ( ) : mixed Get the default value of the parameter.
getDefaultValueAsString ( ) : string Get the default value represented as a string.
getDefaultValueConstantName ( ) : string
getDocBlockTypeStrings ( ) : string[] Get the DocBlock type hints as an array of strings.
getDocBlockTypes ( ) : phpDocumentor\Reflection\Type[] Get the types defined in the DocBlocks. This returns an array because the parameter may have multiple (compound) types specified (for example when you type hint pipe-separated "string|null", in which case this would return an array of Type objects, one for string, one for null.
getName ( ) : string Get the name of the parameter.
getPosition ( ) : integer Find the position of the parameter, left to right, starting at zero.
getType ( ) : ReflectionType | null Get the ReflectionType instance representing the type declaration for this parameter
getTypeHint ( ) : phpDocumentor\Reflection\Type Get the type hint declared for the parameter. This is the real type hint for the parameter, e.g. method(closure $someFunc) defined by the method itself, and is separate from the DocBlock type hints.
hasType ( ) : boolean Does this parameter have a type declaration?
isArray ( ) : boolean Is this parameter an array?
isCallable ( ) : boolean Is this parameter a callable?
isDefaultValueAvailable ( ) : boolean Does the parameter have a default, regardless of whether it is optional.
isDefaultValueConstant ( ) : boolean
isOptional ( ) : boolean Is the parameter optional?
isPassedByReference ( ) : boolean Is this parameter passed by reference (denoted by &$param).
isVariadic ( ) : boolean Is this parameter a variadic (denoted by .
removeType ( ) Remove the parameter type declaration completely.
setType ( phpDocumentor\Reflection\Type $newParameterType ) Set the parameter type declaration.

Private Methods

Méthode Description
__construct ( )
parseDefaultValueNode ( )

Method Details

__clone() public méthode

public __clone ( )

__toString() public méthode

Return string representation of this parameter.
public __toString ( ) : string
Résultat string

allowsNull() public méthode

Does this method allow null for a parameter?
public allowsNull ( ) : boolean
Résultat boolean

canBePassedByValue() public méthode

public canBePassedByValue ( ) : boolean
Résultat boolean

createFromClassInstanceAndMethod() public static méthode

Create a reflection of a parameter using an instance
public static createFromClassInstanceAndMethod ( object $instance, string $methodName, string $parameterName ) : ReflectionParameter
$instance object
$methodName string
$parameterName string
Résultat ReflectionParameter

createFromClassNameAndMethod() public static méthode

Create a reflection of a parameter using a class name
public static createFromClassNameAndMethod ( string $className, string $methodName, string $parameterName ) : ReflectionParameter
$className string
$methodName string
$parameterName string
Résultat ReflectionParameter

createFromNode() public static méthode

public static createFromNode ( BetterReflection\Reflector\Reflector $reflector, Param $node, ReflectionFunctionAbstract $function, integer $parameterIndex ) : ReflectionParameter
$reflector BetterReflection\Reflector\Reflector
$node PhpParser\Node\Param
$function ReflectionFunctionAbstract
$parameterIndex integer
Résultat ReflectionParameter

createFromSpec() public static méthode

- [$instance, 'method'] - ['Foo', 'bar'] - ['foo'] - [function () }]
public static createFromSpec ( string[] | string | Closure $spec, string $parameterName ) : ReflectionParameter
$spec string[] | string | Closure
$parameterName string
Résultat ReflectionParameter

export() public static méthode

public static export ( )

getClass() public méthode

Gets a ReflectionClass for the type hint (returns null if not a class)
public getClass ( ) : ReflectionClass | null
Résultat ReflectionClass | null

getDeclaringClass() public méthode

This will return null if the declaring function is not a method.
public getDeclaringClass ( ) : ReflectionClass | null
Résultat ReflectionClass | null

getDeclaringFunction() public méthode

Get the function (or method) that declared this parameter.
public getDeclaringFunction ( ) : ReflectionFunctionAbstract
Résultat ReflectionFunctionAbstract

getDefaultValue() public méthode

Get the default value of the parameter.
public getDefaultValue ( ) : mixed
Résultat mixed

getDefaultValueAsString() public méthode

Get the default value represented as a string.
public getDefaultValueAsString ( ) : string
Résultat string

getDefaultValueConstantName() public méthode

public getDefaultValueConstantName ( ) : string
Résultat string

getDocBlockTypeStrings() public méthode

Get the DocBlock type hints as an array of strings.
public getDocBlockTypeStrings ( ) : string[]
Résultat string[]

getDocBlockTypes() public méthode

Get the types defined in the DocBlocks. This returns an array because the parameter may have multiple (compound) types specified (for example when you type hint pipe-separated "string|null", in which case this would return an array of Type objects, one for string, one for null.
See also: getTypeHint()
public getDocBlockTypes ( ) : phpDocumentor\Reflection\Type[]
Résultat phpDocumentor\Reflection\Type[]

getName() public méthode

Get the name of the parameter.
public getName ( ) : string
Résultat string

getPosition() public méthode

Find the position of the parameter, left to right, starting at zero.
public getPosition ( ) : integer
Résultat integer

getType() public méthode

(note: this has nothing to do with DocBlocks).
public getType ( ) : ReflectionType | null
Résultat ReflectionType | null

getTypeHint() public méthode

Get the type hint declared for the parameter. This is the real type hint for the parameter, e.g. method(closure $someFunc) defined by the method itself, and is separate from the DocBlock type hints.
See also: getDocBlockTypes()
public getTypeHint ( ) : phpDocumentor\Reflection\Type
Résultat phpDocumentor\Reflection\Type

hasType() public méthode

(note: this has nothing to do with DocBlocks).
public hasType ( ) : boolean
Résultat boolean

isArray() public méthode

Is this parameter an array?
public isArray ( ) : boolean
Résultat boolean

isCallable() public méthode

Is this parameter a callable?
public isCallable ( ) : boolean
Résultat boolean

isDefaultValueAvailable() public méthode

Note this is distinct from "isOptional" because you can have a default value, but the parameter not be optional. In the example, the $foo parameter isOptional() == false, but isDefaultValueAvailable == true
public isDefaultValueAvailable ( ) : boolean
Résultat boolean

isDefaultValueConstant() public méthode

public isDefaultValueConstant ( ) : boolean
Résultat boolean

isOptional() public méthode

Note this is distinct from "isDefaultValueAvailable" because you can have a default value, but the parameter not be optional. In the example, the $foo parameter isOptional() == false, but isDefaultValueAvailable == true
public isOptional ( ) : boolean
Résultat boolean

isPassedByReference() public méthode

Is this parameter passed by reference (denoted by &$param).
public isPassedByReference ( ) : boolean
Résultat boolean

isVariadic() public méthode

..$param).
public isVariadic ( ) : boolean
Résultat boolean

removeType() public méthode

Remove the parameter type declaration completely.
public removeType ( )

setType() public méthode

You must use the phpDocumentor reflection type classes as the parameter.
public setType ( phpDocumentor\Reflection\Type $newParameterType )
$newParameterType phpDocumentor\Reflection\Type