Type
in package
Type value object (immutable).
since Symfony 7.3, use "Symfony\Component\TypeInfo\Type" class from "symfony/type-info" instead
Tags
Table of Contents
Constants
- BUILTIN_TYPE_ARRAY = 'array'
- BUILTIN_TYPE_BOOL = 'bool'
- BUILTIN_TYPE_CALLABLE = 'callable'
- BUILTIN_TYPE_FALSE = 'false'
- BUILTIN_TYPE_FLOAT = 'float'
- BUILTIN_TYPE_INT = 'int'
- BUILTIN_TYPE_ITERABLE = 'iterable'
- BUILTIN_TYPE_NULL = 'null'
- BUILTIN_TYPE_OBJECT = 'object'
- BUILTIN_TYPE_RESOURCE = 'resource'
- BUILTIN_TYPE_STRING = 'string'
- BUILTIN_TYPE_TRUE = 'true'
Properties
- $builtinCollectionTypes : array<string|int, string>
- List of PHP builtin collection types.
- $builtinTypes : array<string|int, string>
- List of PHP builtin types.
- $builtinType : string
- $class : string|null
- $collection : bool
- $collectionKeyType : array<string|int, mixed>
- $collectionValueType : array<string|int, mixed>
- $nullable : bool
Methods
- __construct() : mixed
- getBuiltinType() : string
- Gets built-in type.
- getClassName() : string|null
- Gets the class name.
- getCollectionKeyTypes() : array<string|int, Type>
- Gets collection key types.
- getCollectionValueTypes() : array<string|int, Type>
- Gets collection value types.
- isCollection() : bool
- isNullable() : bool
- validateCollectionArgument() : array<string|int, mixed>|null
Constants
BUILTIN_TYPE_ARRAY
public
mixed
BUILTIN_TYPE_ARRAY
= 'array'
BUILTIN_TYPE_BOOL
public
mixed
BUILTIN_TYPE_BOOL
= 'bool'
BUILTIN_TYPE_CALLABLE
public
mixed
BUILTIN_TYPE_CALLABLE
= 'callable'
BUILTIN_TYPE_FALSE
public
mixed
BUILTIN_TYPE_FALSE
= 'false'
BUILTIN_TYPE_FLOAT
public
mixed
BUILTIN_TYPE_FLOAT
= 'float'
BUILTIN_TYPE_INT
public
mixed
BUILTIN_TYPE_INT
= 'int'
BUILTIN_TYPE_ITERABLE
public
mixed
BUILTIN_TYPE_ITERABLE
= 'iterable'
BUILTIN_TYPE_NULL
public
mixed
BUILTIN_TYPE_NULL
= 'null'
BUILTIN_TYPE_OBJECT
public
mixed
BUILTIN_TYPE_OBJECT
= 'object'
BUILTIN_TYPE_RESOURCE
public
mixed
BUILTIN_TYPE_RESOURCE
= 'resource'
BUILTIN_TYPE_STRING
public
mixed
BUILTIN_TYPE_STRING
= 'string'
BUILTIN_TYPE_TRUE
public
mixed
BUILTIN_TYPE_TRUE
= 'true'
Properties
$builtinCollectionTypes
List of PHP builtin collection types.
public
static array<string|int, string>
$builtinCollectionTypes
= [self::BUILTIN_TYPE_ARRAY, self::BUILTIN_TYPE_ITERABLE]
$builtinTypes
List of PHP builtin types.
public
static array<string|int, string>
$builtinTypes
= [self::BUILTIN_TYPE_INT, self::BUILTIN_TYPE_FLOAT, self::BUILTIN_TYPE_STRING, self::BUILTIN_TYPE_BOOL, self::BUILTIN_TYPE_RESOURCE, self::BUILTIN_TYPE_OBJECT, self::BUILTIN_TYPE_ARRAY, self::BUILTIN_TYPE_CALLABLE, self::BUILTIN_TYPE_FALSE, self::BUILTIN_TYPE_TRUE, self::BUILTIN_TYPE_NULL, self::BUILTIN_TYPE_ITERABLE]
$builtinType
private
string
$builtinType
$class
private
string|null
$class
= null
$collection
private
bool
$collection
= false
$collectionKeyType
private
array<string|int, mixed>
$collectionKeyType
$collectionValueType
private
array<string|int, mixed>
$collectionValueType
$nullable
private
bool
$nullable
= false
Methods
__construct()
public
__construct(string $builtinType[, bool $nullable = false ][, string|null $class = null ][, bool $collection = false ][, array<string|int, Type>|Type|null $collectionKeyType = null ][, array<string|int, Type>|Type|null $collectionValueType = null ]) : mixed
Parameters
- $builtinType : string
- $nullable : bool = false
- $class : string|null = null
- $collection : bool = false
- $collectionKeyType : array<string|int, Type>|Type|null = null
- $collectionValueType : array<string|int, Type>|Type|null = null
Tags
getBuiltinType()
Gets built-in type.
public
getBuiltinType() : string
Can be bool, int, float, string, array, object, resource, null, callback or iterable.
Return values
stringgetClassName()
Gets the class name.
public
getClassName() : string|null
Only applicable if the built-in type is object.
Return values
string|nullgetCollectionKeyTypes()
Gets collection key types.
public
getCollectionKeyTypes() : array<string|int, Type>
Only applicable for a collection type.
Return values
array<string|int, Type>getCollectionValueTypes()
Gets collection value types.
public
getCollectionValueTypes() : array<string|int, Type>
Only applicable for a collection type.
Return values
array<string|int, Type>isCollection()
public
isCollection() : bool
Return values
boolisNullable()
public
isNullable() : bool
Return values
boolvalidateCollectionArgument()
private
validateCollectionArgument(array<string|int, mixed>|self|null $collectionArgument, int $argumentIndex, string $argumentName) : array<string|int, mixed>|null
Parameters
- $collectionArgument : array<string|int, mixed>|self|null
- $argumentIndex : int
- $argumentName : string