TypeHandlingUtility
PHP type handling functions
only to be used within Extbase, not part of TYPO3 Core API.
Table of Contents
Constants
- LITERAL_TYPE_PATTERN = '/^(?:integer|int|float|double|boolean|bool|string)$/'
- A type pattern to detect literal types.
- PARSE_TYPE_PATTERN = '/^\\\\?(?P<type>integer|int|float|double|boolean|bool|string|DateTimeImmutable|DateTime|[A-Z][a-zA-Z0-9\\\\]+|object|resource|array|ArrayObject|SplObjectStorage|TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage)(?:<\\\\?(?P<elementType>[a-zA-Z0-9\\\\]+)>)?/'
- A property type parse pattern.
Properties
- $collectionTypes : array<string|int, mixed>
Methods
- isCollectionType() : bool
- Returns TRUE if the $type is a collection type.
- isCoreType() : bool
- Returns TRUE if the $type is a CMS core type object.
- isLiteral() : bool
- Returns TRUE if the $type is a literal.
- isSimpleType() : bool
- Returns TRUE if the $type is a simple type.
- isValidTypeForMultiValueComparison() : bool
- Returns TRUE when the given value can be used in an "in" comparison in a query.
- normalizeType() : string
- Normalize data types so they match the PHP type names: int -> integer double -> float bool -> boolean
- parseType() : array<string|int, mixed>
- Returns an array with type information, including element type for collection types (array, SplObjectStorage, ...)
Constants
LITERAL_TYPE_PATTERN
A type pattern to detect literal types.
public
mixed
LITERAL_TYPE_PATTERN
= '/^(?:integer|int|float|double|boolean|bool|string)$/'
PARSE_TYPE_PATTERN
A property type parse pattern.
public
mixed
PARSE_TYPE_PATTERN
= '/^\\\\?(?P<type>integer|int|float|double|boolean|bool|string|DateTimeImmutable|DateTime|[A-Z][a-zA-Z0-9\\\\]+|object|resource|array|ArrayObject|SplObjectStorage|TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage)(?:<\\\\?(?P<elementType>[a-zA-Z0-9\\\\]+)>)?/'
Properties
$collectionTypes
protected
static array<string|int, mixed>
$collectionTypes
= ['array', \ArrayObject::class, \SplObjectStorage::class, \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class]
Methods
isCollectionType()
Returns TRUE if the $type is a collection type.
public
static isCollectionType(string $type) : bool
Parameters
- $type : string
Return values
boolisCoreType()
Returns TRUE if the $type is a CMS core type object.
public
static isCoreType(string|object $type) : bool
Parameters
- $type : string|object
Return values
boolisLiteral()
Returns TRUE if the $type is a literal.
public
static isLiteral(string $type) : bool
Parameters
- $type : string
Return values
boolisSimpleType()
Returns TRUE if the $type is a simple type.
public
static isSimpleType(string $type) : bool
Parameters
- $type : string
Return values
boolisValidTypeForMultiValueComparison()
Returns TRUE when the given value can be used in an "in" comparison in a query.
public
static isValidTypeForMultiValueComparison(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolnormalizeType()
Normalize data types so they match the PHP type names: int -> integer double -> float bool -> boolean
public
static normalizeType(string $type) : string
Parameters
- $type : string
-
Data type to unify
Return values
string —unified data type
parseType()
Returns an array with type information, including element type for collection types (array, SplObjectStorage, ...)
public
static parseType(string $type) : array<string|int, mixed>
Parameters
- $type : string
-
Type of the property (see PARSE_TYPE_PATTERN)
Tags
Return values
array<string|int, mixed> —An array with information about the type