[TASK] Update phpdocumentor/reflection-docblock 38/62438/7
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Wed, 27 Nov 2019 14:53:24 +0000 (15:53 +0100)
committerSusanne Moog <look@susi.dev>
Wed, 22 Jan 2020 13:20:02 +0000 (14:20 +0100)
    composer require phpdocumentor/reflection-docblock:"^4.3.2"
    composer require phpdocumentor/type-resolver:"~0.5"

Upating phpdocumentor/reflection-docblock to at least 4.3.2
allows updating phpdocumentor/type-resolver to a version higher
than 0.4 which is needed to get support for resolving collection
types in doc blocks which enables the removal of the custom type
resolving via extbase/Classes/Reflection/DocBlock/Tags/Var_.php.

Releases: master
Resolves: #89795
Change-Id: I2126dd9362e51f6dae9e6103c219295c5c3d679b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62438
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Susanne Moog <look@susi.dev>
Build/Scripts/docBlockChecker.php
composer.json
composer.lock
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/extbase/Classes/Reflection/ClassSchema.php
typo3/sysext/extbase/Classes/Reflection/DocBlock/Tags/Var_.php [deleted file]
typo3/sysext/extbase/composer.json

index d429a44..9f7c32e 100755 (executable)
@@ -21,7 +21,6 @@ use PhpParser\Node;
 use PhpParser\NodeTraverser;
 use PhpParser\ParserFactory;
 use Symfony\Component\Console\Output\ConsoleOutput;
-use TYPO3\CMS\Extbase\Reflection\DocBlock\Tags\Var_;
 
 require_once __DIR__ . '/../../vendor/autoload.php';
 
@@ -76,7 +75,6 @@ class NodeVisitor implements \PhpParser\NodeVisitor
     public function beforeTraverse(array $nodes)
     {
         $this->docBlockFactory = DocBlockFactory::createInstance();
-        $this->docBlockFactory->registerTagHandler('var', Var_::class);
         return null;
     }
 
index c8951be..2cc0b5b 100644 (file)
@@ -44,7 +44,8 @@
                "doctrine/lexer": "^1.0",
                "guzzlehttp/guzzle": "^6.3.0",
                "nikic/php-parser": "^4.3",
-               "phpdocumentor/reflection-docblock": "^4.3",
+               "phpdocumentor/reflection-docblock": "^4.3.2",
+               "phpdocumentor/type-resolver": "~0.5",
                "psr/container": "^1.0",
                "psr/event-dispatcher": "^1.0",
                "psr/http-client": "^1.0",
@@ -93,8 +94,7 @@
        },
        "conflict": {
                "hoa/core": "*",
-               "guzzlehttp/guzzle": ">= 6.5.0",
-               "phpdocumentor/reflection-docblock": ">= 4.3.2"
+               "guzzlehttp/guzzle": ">= 6.5.0"
        },
        "provide": {
                "psr/http-client-implementation": "1.0",
index 6e778b5..9e85a33 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "daf37d00689135848528f707a4b893d2",
+    "content-hash": "776eed8d0ec9365f10766d84c53d1be2",
     "packages": [
         {
             "name": "cogpowered/finediff",
         },
         {
             "name": "phpdocumentor/reflection-docblock",
-            "version": "4.3.1",
+            "version": "4.3.4",
             "source": {
                 "type": "git",
                 "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
-                "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c"
+                "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c",
-                "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c",
+                "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c",
+                "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c",
                 "shasum": ""
             },
             "require": {
                 "php": "^7.0",
-                "phpdocumentor/reflection-common": "^1.0.0",
-                "phpdocumentor/type-resolver": "^0.4.0",
+                "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0",
+                "phpdocumentor/type-resolver": "~0.4 || ^1.0.0",
                 "webmozart/assert": "^1.0"
             },
             "require-dev": {
-                "doctrine/instantiator": "~1.0.5",
+                "doctrine/instantiator": "^1.0.5",
                 "mockery/mockery": "^1.0",
+                "phpdocumentor/type-resolver": "0.4.*",
                 "phpunit/phpunit": "^6.4"
             },
             "type": "library",
                 }
             ],
             "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
-            "time": "2019-04-30T17:48:53+00:00"
+            "time": "2019-12-28T18:55:12+00:00"
         },
         {
             "name": "phpdocumentor/type-resolver",
-            "version": "0.4.0",
+            "version": "0.5.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/phpDocumentor/TypeResolver.git",
-                "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7"
+                "reference": "cf842904952e64e703800d094cdf34e715a8a3ae"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7",
-                "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7",
+                "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/cf842904952e64e703800d094cdf34e715a8a3ae",
+                "reference": "cf842904952e64e703800d094cdf34e715a8a3ae",
                 "shasum": ""
             },
             "require": {
-                "php": "^5.5 || ^7.0",
+                "php": "^7.0",
                 "phpdocumentor/reflection-common": "^1.0"
             },
             "require-dev": {
-                "mockery/mockery": "^0.9.4",
-                "phpunit/phpunit": "^5.2||^4.8.24"
+                "mockery/mockery": "^1.0",
+                "phpunit/phpunit": "^6.4"
             },
             "type": "library",
             "extra": {
             },
             "autoload": {
                 "psr-4": {
-                    "phpDocumentor\\Reflection\\": [
-                        "src/"
-                    ]
+                    "phpDocumentor\\Reflection\\": "src"
                 }
             },
             "notification-url": "https://packagist.org/downloads/",
                     "email": "me@mikevanriel.com"
                 }
             ],
-            "time": "2017-07-14T14:27:02+00:00"
+            "time": "2017-12-30T13:23:38+00:00"
         },
         {
             "name": "psr/cache",
                 "selenium",
                 "webdriver"
             ],
+            "abandoned": "php-webdriver/webdriver",
             "time": "2018-05-16T17:37:13+00:00"
         },
         {
index 324d95b..10f8c82 100644 (file)
@@ -68,7 +68,7 @@ class GeneralUtility
     /**
      * Instances returned by makeInstance, using the class names as array keys
      *
-     * @var array<array><object>
+     * @var array<object>
      */
     protected static $nonSingletonInstances = [];
 
index a1b99ae..206e3cf 100644 (file)
@@ -42,7 +42,6 @@ use TYPO3\CMS\Extbase\Reflection\ClassSchema\Method;
 use TYPO3\CMS\Extbase\Reflection\ClassSchema\Property;
 use TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics;
 use TYPO3\CMS\Extbase\Reflection\DocBlock\Tags\Null_;
-use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility;
 use TYPO3\CMS\Extbase\Validation\Exception\InvalidTypeHintException;
 use TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationConfigurationException;
 use TYPO3\CMS\Extbase\Validation\ValidatorClassNameResolver;
@@ -149,7 +148,6 @@ class ClassSchema
 
         if (self::$propertyInfoExtractor === null) {
             $docBlockFactory = DocBlockFactory::createInstance();
-            $docBlockFactory->registerTagHandler('var', DocBlock\Tags\Var_::class);
             $phpDocExtractor = new PhpDocExtractor($docBlockFactory);
 
             $reflectionExtractor = new ReflectionExtractor();
@@ -253,34 +251,33 @@ class ClassSchema
                 $classHasInjectProperties = true;
             }
 
+            $this->properties[$propertyName]['propertyCharacteristicsBit'] = $propertyCharacteristicsBit;
+
             /** @var Type[] $types */
             $types = (array)self::$propertyInfoExtractor->getTypes($this->className, $propertyName, ['reflectionProperty' => $reflectionProperty]);
             $typesCount = count($types);
 
-            if ($typesCount > 0
-                && ($annotation = $annotationReader->getPropertyAnnotation($reflectionProperty, Cascade::class)) instanceof Cascade
-            ) {
+            if ($typesCount !== 1) {
+                continue;
+            }
+
+            if (($annotation = $annotationReader->getPropertyAnnotation($reflectionProperty, Cascade::class)) instanceof Cascade) {
                 /** @var Cascade $annotation */
                 $this->properties[$propertyName]['c'] = $annotation->value;
             }
 
-            if ($typesCount === 1) {
-                $this->properties[$propertyName]['t'] = $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]['t'] = ltrim($actualType, '\\');
-                    $this->properties[$propertyName]['e'] = ltrim($elementType->getCollectionValueType()->getClassName(), '\\');
+            /** @var Type $type */
+            $type = current($types);
+
+            if ($type->isCollection()) {
+                $this->properties[$propertyName]['t'] = ltrim($type->getClassName() ?? $type->getBuiltinType(), '\\');
+
+                if (($collectionValueType = $type->getCollectionValueType()) instanceof Type) {
+                    $this->properties[$propertyName]['e'] = ltrim($collectionValueType->getClassName() ?? $type->getBuiltinType(), '\\');
                 }
+            } else {
+                $this->properties[$propertyName]['t'] = $types[0]->getClassName() ?? $types[0]->getBuiltinType();
             }
-
-            $this->properties[$propertyName]['propertyCharacteristicsBit'] = $propertyCharacteristicsBit;
         }
 
         if ($classHasInjectProperties) {
diff --git a/typo3/sysext/extbase/Classes/Reflection/DocBlock/Tags/Var_.php b/typo3/sysext/extbase/Classes/Reflection/DocBlock/Tags/Var_.php
deleted file mode 100644 (file)
index fc4ec12..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-declare(strict_types = 1);
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-namespace TYPO3\CMS\Extbase\Reflection\DocBlock\Tags;
-
-use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
-use phpDocumentor\Reflection\TypeResolver;
-use phpDocumentor\Reflection\Types\Compound;
-use phpDocumentor\Reflection\Types\Context as TypeContext;
-use Webmozart\Assert\Assert;
-
-/**
- * Class TYPO3\CMS\Extbase\Reflection\DocBlock\Tags\Var_
- */
-class Var_ extends \phpDocumentor\Reflection\DocBlock\Tags\Var_
-{
-    /**
-     * @param $body
-     * @param TypeResolver|null $typeResolver
-     * @param DescriptionFactory|null $descriptionFactory
-     * @param TypeContext|null $context
-     * @return \phpDocumentor\Reflection\DocBlock\Tags\Var_|Var_
-     */
-    public static function create(
-        $body,
-        TypeResolver $typeResolver = null,
-        DescriptionFactory $descriptionFactory = null,
-        TypeContext $context = null
-    ) {
-        /*
-         * This class is needed to detect collections like
-         * @var Collection<CollectionType>
-         *
-         * While writing this comment, TYPO3 has a dependency to
-         * phpdocumentor/type-resolver:^0.4.0 via
-         * phpdocumentor/reflection-docblock:4.3.0.
-         *
-         * phpdocumentor/type-resolver can detect collections from
-         * version 0.5.0 on, but as there is no newer version of
-         * phpdocumentor/reflection-docblock, this feature is
-         * unavailable at the moment.
-         *
-         * Once phpdocumentor/reflection-docblock:5.0.0 has been
-         * released, TYPO3 should use that version along with an
-         * updated version of phpdocumentor/type-resolver and
-         * this class should be removed then.
-         */
-        Assert::stringNotEmpty($body);
-        Assert::allNotNull([$typeResolver, $descriptionFactory]);
-
-        $parts        = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
-        $type         = null;
-        $variableName = '';
-
-        // if the first item that is encountered is not a variable; it is a type
-        if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) {
-            $currentPart = array_shift($parts);
-
-            $matches = [];
-            $pattern = '/(?P<type>[^\s<>]+)<(?P<elementType>[^\s<>]+)>/';
-            if (preg_match($pattern, $currentPart, $matches)) {
-                $type = new Compound([
-                    $typeResolver->resolve($matches['type'], $context),
-                    $typeResolver->resolve($matches['elementType'] . '[]', $context),
-                ]);
-            } else {
-                $type = $typeResolver->resolve($currentPart, $context);
-            }
-
-            array_shift($parts);
-        }
-
-        // if the next item starts with a $ or ...$ it must be the variable name
-        if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
-            $variableName = array_shift($parts);
-            array_shift($parts);
-
-            if (substr($variableName, 0, 1) === '$') {
-                $variableName = substr($variableName, 1);
-            }
-        }
-
-        $description = $descriptionFactory->create(implode('', $parts), $context);
-
-        return new static($variableName, $type, $description);
-    }
-}
index df797c6..cd0f7a4 100644 (file)
@@ -13,7 +13,8 @@
                "sort-packages": true
        },
        "require": {
-               "phpdocumentor/reflection-docblock": "^4.3",
+               "phpdocumentor/reflection-docblock": "^4.3.2",
+               "phpdocumentor/type-resolver": "~0.5",
                "symfony/dependency-injection": "^4.4 || ^5.0",
                "symfony/property-access": "^4.4 || ^5.0",
                "symfony/property-info": "^4.4 || ^5.0",