8000 [ErrorHandler] fix parsing `@return array<foo>` annotations · symfony/symfony@b8cbb93 · GitHub
[go: up one dir, main page]

Skip to content

Commit b8cbb93

Browse files
[ErrorHandler] fix parsing @return array<foo> annotations
1 parent 6c8114a commit b8cbb93

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/ErrorHandler/DebugClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
612612
;
613613
}
614614

615-
if (null !== ($returnType = self::$returnTypes[$class][$method->name] ?? self::MAGIC_METHODS[$method->name] ?? null) && !$method->hasReturnType() && !($doc && preg_match('/\n\s+\* @return +(\S+)/', $doc))) {
615+
if (null !== ($returnType = self::$returnTypes[$class][$method->name] ?? self::MAGIC_METHODS[$method->name] ?? null) && !$method->hasReturnType() && !($doc && preg_match('/\n\s+\* @return +([^\s<(]+)/', $doc))) {
616616
[$normalizedType, $returnType, $declaringClass, $declaringFile] = \is_string($returnType) ? [$returnType, $returnType, '', ''] : $returnType;
617617

618618
if ('void' === $normalizedType) {
@@ -640,7 +640,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
640640

641641
$matches = [];
642642

643-
if (!$method->hasReturnType() && ((false !== strpos($doc, '@return') && preg_match('/\n\s+\* @return +(\S+)/', $doc, $matches)) || 'void' !== (self::MAGIC_METHODS[$method->name] ?? 'void'))) {
643+
if (!$method->hasReturnType() && ((false !== strpos($doc, '@return') && preg_match('/\n\s+\* @return +([^\s<(]+)/', $doc, $matches)) || 'void' !== (self::MAGIC_METHODS[$method->name] ?? 'void'))) {
644644
$matches = $matches ?: [1 => self::MAGIC_METHODS[$method->name]];
645645
$this->setReturnType($matches[1], $method, $parent);
646646

0 commit comments

Comments
 (0)
0