[ErrorHandler] fix parsing `@return array<foo>` annotations

This commit is contained in:
Nicolas Grekas 2021-07-15 11:09:11 +02:00
parent 6c8114ad2a
commit b8cbb93caa
1 changed files with 2 additions and 2 deletions

View File

@ -612,7 +612,7 @@ class DebugClassLoader
;
}
if (null !== ($returnType = self::$returnTypes[$class][$method->name] ?? self::MAGIC_METHODS[$method->name] ?? null) && !$method->hasReturnType() && !($doc && preg_match('/\n\s+\* @return +(\S+)/', $doc))) {
if (null !== ($returnType = self::$returnTypes[$class][$method->name] ?? self::MAGIC_METHODS[$method->name] ?? null) && !$method->hasReturnType() && !($doc && preg_match('/\n\s+\* @return +([^\s<(]+)/', $doc))) {
[$normalizedType, $returnType, $declaringClass, $declaringFile] = \is_string($returnType) ? [$returnType, $returnType, '', ''] : $returnType;
if ('void' === $normalizedType) {
@ -640,7 +640,7 @@ class DebugClassLoader
$matches = [];
if (!$method->hasReturnType() && ((false !== strpos($doc, '@return') && preg_match('/\n\s+\* @return +(\S+)/', $doc, $matches)) || 'void' !== (self::MAGIC_METHODS[$method->name] ?? 'void'))) {
if (!$method->hasReturnType() && ((false !== strpos($doc, '@return') && preg_match('/\n\s+\* @return +([^\s<(]+)/', $doc, $matches)) || 'void' !== (self::MAGIC_METHODS[$method->name] ?? 'void'))) {
$matches = $matches ?: [1 => self::MAGIC_METHODS[$method->name]];
$this->setReturnType($matches[1], $method, $parent);