[BUGFIX] ClassSchema must analyze all property doc blocks 46/59846/4
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Mon, 4 Mar 2019 18:23:39 +0000 (18:23 +0000)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 7 Mar 2019 19:44:45 +0000 (20:44 +0100)
While introducing symfony/property-info with
https://review.typo3.org/c/Packages/TYPO3.CMS/+/59454,
the analyzing of property doc blocks changed. Before,
all properties had been analyzed but with that commit,
the analyzing had been reduced to inject and collection
properties. This however breaks the validation which is
based on knowing the type of properties.

Releases: master
Resolves: #87838
Relates: #87457
Change-Id: I171cbbe1bf1cc6d6bac235bd6158c2864c7deb4a
Reviewed-on: https://review.typo3.org/c/59846
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/extbase/Classes/Reflection/ClassSchema.php

index 4aa4860..acbcb3b 100644 (file)
@@ -263,16 +263,9 @@ class ClassSchema
             $isInjectProperty = $propertyName !== 'settings'
                 && ($annotationReader->getPropertyAnnotation($reflectionProperty, Inject::class) instanceof Inject);
 
-            $isPossibleCollectionProperty = $annotationReader->getPropertyAnnotation($reflectionProperty, Transient::class) === null
-                && $this->isModel();
-
-            $types = [];
-            $typesCount = 0;
-            if ($isInjectProperty || $isPossibleCollectionProperty) {
-                /** @var Type[] $types */
-                $types = (array)self::$propertyInfoExtractor->getTypes($this->className, $propertyName);
-                $typesCount = count($types);
-            }
+            /** @var Type[] $types */
+            $types = (array)self::$propertyInfoExtractor->getTypes($this->className, $propertyName);
+            $typesCount = count($types);
 
             if ($typesCount > 0
                 && ($annotation = $annotationReader->getPropertyAnnotation($reflectionProperty, Cascade::class)) instanceof Cascade
@@ -289,21 +282,19 @@ class ClassSchema
                 $this->injectProperties[] = $propertyName;
             }
 
-            if ($isPossibleCollectionProperty) {
-                if ($typesCount === 1) {
-                    $this->properties[$propertyName]['type'] = $types[0]->getClassName() ?? $types[0]->getBuiltinType();
-                } elseif ($typesCount === 2) {
-                    [$type, $elementType] = $types;
-                    $actualType = $type->getClassName() ?? $type->getBuiltinType();
-
-                    if (TypeHandlingUtility::isCollectionType($actualType)
-                        && $elementType->getBuiltinType() === 'array'
-                        && $elementType->getCollectionValueType() instanceof Type
-                        && $elementType->getCollectionValueType()->getClassName() !== null
-                    ) {
-                        $this->properties[$propertyName]['type'] = ltrim($actualType, '\\');
-                        $this->properties[$propertyName]['elementType'] = ltrim($elementType->getCollectionValueType()->getClassName(), '\\');
-                    }
+            if ($typesCount === 1) {
+                $this->properties[$propertyName]['type'] = $types[0]->getClassName() ?? $types[0]->getBuiltinType();
+            } elseif ($typesCount === 2) {
+                [$type, $elementType] = $types;
+                $actualType = $type->getClassName() ?? $type->getBuiltinType();
+
+                if (TypeHandlingUtility::isCollectionType($actualType)
+                    && $elementType->getBuiltinType() === 'array'
+                    && $elementType->getCollectionValueType() instanceof Type
+                    && $elementType->getCollectionValueType()->getClassName() !== null
+                ) {
+                    $this->properties[$propertyName]['type'] = ltrim($actualType, '\\');
+                    $this->properties[$propertyName]['elementType'] = ltrim($elementType->getCollectionValueType()->getClassName(), '\\');
                 }
             }
         }