ParameterType
extends Type
in package
Table of Contents
- CONTRAVARIANT = 0x1 << 8
- Contravariant parameters allow implementors to specify a supertype of that which is specified in the prototype
- COVARIANT = 0x2 << 8
- Covariant parameters allow implementors to specify a subtype of that which is specified in the prototype Usually this isn't a good idea, it's not type-safe, do not use unless you understand what you are doing!
- NULLABLE = 0x2
- Nullable types are either explicitly ?type (PHP>=7.1) or with a default value of null
- OPTIONAL = 0x8 << 8
- An optional parameter may be omitted at call time
- REFERENCE = 0x4
- Reference types must always match
- VARIADIC = 0x4 << 8
- A variadic parameter accepts zero or more arguments of the specified type
- WEAK = 0x1
- Weak mode validates types using the same rules are strict_types=0
- $allowsContravariance : bool
- Whether the type allows contravariant matches
- $allowsCovariance : bool
- Whether the type allows covariant matches
- $isByReference : bool
- Whether the type is passed by reference
- $isNullable : bool
- Whether the type is nullable
- $isOptional : bool
- Whether the parameter value can be omitted at call time#
- $isVariadic : bool
- Whether the parameter accepts multiple values
- $isWeak : bool
- Whether the type should be matched in weak mode
- $typeName : string|null
- The name of the type
- $parameterName : string
- The name of the parameter in the prototype
- __construct() : mixed
- __toString() : string
- createFromReflectionParameter() : ParameterType
- Create a new ParameterType instance from a \ReflectionParameter instance
- isSatisfiedBy() : bool
- Whether the type will be satisfied by the specified type name, nullability and by-reference combination
Constants
CONTRAVARIANT
Contravariant parameters allow implementors to specify a supertype of that which is specified in the prototype
public
mixed
CONTRAVARIANT
= 0x1 << 8
COVARIANT
Covariant parameters allow implementors to specify a subtype of that which is specified in the prototype Usually this isn't a good idea, it's not type-safe, do not use unless you understand what you are doing!
public
mixed
COVARIANT
= 0x2 << 8
NULLABLE
Nullable types are either explicitly ?type (PHP>=7.1) or with a default value of null
public
mixed
NULLABLE
= 0x2
OPTIONAL
An optional parameter may be omitted at call time
public
mixed
OPTIONAL
= 0x8 << 8
REFERENCE
Reference types must always match
public
mixed
REFERENCE
= 0x4
VARIADIC
A variadic parameter accepts zero or more arguments of the specified type
public
mixed
VARIADIC
= 0x4 << 8
WEAK
Weak mode validates types using the same rules are strict_types=0
public
mixed
WEAK
= 0x1
Properties
$allowsContravariance
Whether the type allows contravariant matches
public
bool
$allowsContravariance
$allowsCovariance
Whether the type allows covariant matches
public
bool
$allowsCovariance
$isByReference
Whether the type is passed by reference
public
bool
$isByReference
$isNullable
Whether the type is nullable
public
bool
$isNullable
$isOptional
Whether the parameter value can be omitted at call time#
public
bool
$isOptional
$isVariadic
Whether the parameter accepts multiple values
public
bool
$isVariadic
$isWeak
Whether the type should be matched in weak mode
public
bool
$isWeak
$typeName
The name of the type
public
string|null
$typeName
$parameterName
The name of the parameter in the prototype
private
string
$parameterName
Methods
__construct()
public
__construct(string $parameterName[, string|null $typeName = null ][, int $flags = self::CONTRAVARIANT ]) : mixed
Parameters
- $parameterName : string
- $typeName : string|null = null
- $flags : int = self::CONTRAVARIANT
Return values
mixed —__toString()
public
__toString() : string
Return values
string —createFromReflectionParameter()
Create a new ParameterType instance from a \ReflectionParameter instance
public
static createFromReflectionParameter(ReflectionParameter $reflection[, int $flags = 0 ]) : ParameterType
Parameters
- $reflection : ReflectionParameter
- $flags : int = 0
Return values
ParameterType —isSatisfiedBy()
Whether the type will be satisfied by the specified type name, nullability and by-reference combination
public
isSatisfiedBy(string|null $typeName, bool $nullable, bool $byReference) : bool
Parameters
- $typeName : string|null
- $nullable : bool
- $byReference : bool