23 const PARSE_TYPE_PATTERN =
'/^\\\\?(?P<type>integer|int|float|double|boolean|bool|string|DateTime|Tx_[a-zA-Z0-9_]+|[A-Z][a-zA-Z0-9\\\\_]+|object|array|ArrayObject|SplObjectStorage|TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage|Tx_Extbase_Persistence_ObjectStorage)(?:<\\\\?(?P<elementType>[a-zA-Z0-9\\\\_]+)>)?/';
33 static protected $collectionTypes = array(
'array',
'ArrayObject',
'SplObjectStorage',
'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage',
'Tx_Extbase_Persistence_ObjectStorage');
45 if (preg_match(self::PARSE_TYPE_PATTERN, $type, $matches)) {
46 $type = self::normalizeType($matches[
'type']);
47 $elementType = isset($matches[
'elementType']) ? self::normalizeType($matches[
'elementType']) : NULL;
49 if ($elementType !== NULL && !self::isCollectionType($type)) {
50 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);
55 'elementType' => $elementType
58 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);
93 return preg_match(self::LITERAL_TYPE_PATTERN, $type) === 1;
103 return in_array(self::normalizeType($type), array(
'array',
'string',
'float',
'integer',
'boolean'), TRUE);
113 return is_subclass_of($type,
'TYPO3\\CMS\\Core\\Type\\TypeInterface');
123 if (in_array($type, self::$collectionTypes, TRUE)) {
127 if (class_exists($type) === TRUE || interface_exists($type) === TRUE) {
128 foreach (self::$collectionTypes as $collectionType) {
129 if (is_subclass_of($type, $collectionType) === TRUE) {
144 static public function hex2bin($hexadecimalData) {
146 $length = strlen($hexadecimalData);
147 for ($i = 0; $i < $length; $i += 2) {
148 $binaryData .= pack(
'C', hexdec(substr($hexadecimalData, $i, 2)));
static normalizeType($type)
static isCollectionType($type)
static hex2bin($hexadecimalData)
static isSimpleType($type)
const LITERAL_TYPE_PATTERN