Skip to content

Return value parseTypes() is bad #141

Closed
@TrueType

Description

@TrueType

phpDocumentor v1.5.1 on TYPO3v10.4.21 with PHPv7.4.19

Extbase Variable Dump

array(1 item)
   0 => phpDocumentor\Reflection\Types\Object_prototype object
      fqsen => privatephpDocumentor\Reflection\Fqsenprototype object

Extbase Variable Dump

array(1 item)
    => phpDocumentor\Reflection\Types\Array_prototype object
      valueType => protectedphpDocumentor\Reflection\Types\Mixed_prototype object
      keyType => protected NULL
      defaultKeyType => protectedphpDocumentor\Reflection\Types\Compoundprototype object


(1/1) TypeError

Return value of phpDocumentor\Reflection\TypeResolver::parseTypes() must implement interface phpDocumentor\Reflection\Type, null returned
in /var/webroot/vendor/phpdocumentor/type-resolver/src/TypeResolver.php line 320

                );
            }
        } elseif (count($types) === 1) {
            return $types[0];
        }

        if ($compoundToken === '|') {
            return new Compound(array_values($types));

at phpDocumentor\Reflection\TypeResolver->parseTypes()
in /vendor/phpdocumentor/type-resolver/src/TypeResolver.php line 172


        /** @var ArrayIterator<int, string|null> $tokenIterator */
        $tokenIterator = new ArrayIterator($tokens);

        return $this->parseTypes($tokenIterator, $context, self::PARSER_IN_COMPOUND);
    }

    /**
     * Analyse each tokens and creates types

at phpDocumentor\Reflection\TypeResolver->resolve()
in /vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php line 68

        $variableName = '';

        // if the first item that is encountered is not a variable; it is a type
        if ($firstPart && $firstPart[0] !== '$') {
            $type = $typeResolver->resolve($firstPart, $context);
        } else {
            // first part is not a type; we should prepend it to the parts array for further processing
            array_unshift($parts, $firstPart);
        }

at phpDocumentor\Reflection\DocBlock\Tags\Var_::create()
in /vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php line 217

        try {
            $callable = [$handlerClassName, 'create'];
            Assert::isCallable($callable);
            /** @phpstan-var callable(string): ?Tag $callable */
            $tag = call_user_func_array($callable, $arguments);

            return $tag ?? InvalidTag::create($body, $name);
        } catch (InvalidArgumentException $e) {
            return InvalidTag::create($body, $name)->withError($e);
Index: src/TypeResolver.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/TypeResolver.php	(date 1615285713667)
+++ src/TypeResolver.php	(date 1615285713667)
@@ -217,7 +217,7 @@
             }
         } elseif (count($types) === 1) {
-            return $types[0];
+            return $types[0] ? $types[0] : array_values($types)[0];
         }

         if ($compoundToken === '|') {

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions