23 const 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\\\\]+)>)?/';
33 protected static $collectionTypes = [
'array',
'ArrayObject',
'SplObjectStorage', \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class];
46 if (preg_match(self::PARSE_TYPE_PATTERN, $type, $matches)) {
48 $elementType = isset($matches[
'elementType']) ?
self::normalizeType($matches[
'elementType']) :
null;
50 if ($elementType !==
null && !self::isCollectionType($type)) {
51 throw new \TYPO3\CMS\Extbase\Utility\Exception\InvalidTypeException(
'Found an invalid element type declaration in %s. Type "' . $type .
'" must not have an element type hint (' . $elementType .
').', 1264093642);
56 'elementType' => $elementType
59 throw new \TYPO3\CMS\Extbase\Utility\Exception\InvalidTypeException(
'Found an invalid element type declaration in %s. A type "' . var_export($type,
true) .
'" does not exist.', 1264093630);
95 return preg_match(self::LITERAL_TYPE_PATTERN, $type) === 1;
106 return in_array(self::normalizeType($type), [
'array',
'string',
'float',
'integer',
'boolean'],
true);
117 return is_subclass_of($type, \
TYPO3\CMS\Core\Type\TypeInterface::class);
128 if (in_array($type, self::$collectionTypes,
true)) {
132 if (class_exists($type) ===
true || interface_exists($type) ===
true) {
133 foreach (self::$collectionTypes as $collectionType) {
134 if (is_subclass_of($type, $collectionType) ===
true) {
151 return is_array($value) || $value instanceof \Traversable;
160 public static function hex2bin($hexadecimalData)
163 $length = strlen($hexadecimalData);
164 for ($i = 0; $i < $length; $i += 2) {
165 $binaryData .= pack(
'C', hexdec(substr($hexadecimalData, $i, 2)));