diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php index 59805870186..38f524b668d 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php @@ -356,7 +356,12 @@ public static function parse( $method_tree = $parse_tree_creator->create(); } catch (TypeParseTreeException $e) { - throw new DocblockParseException($method_entry . ' is not a valid method'); + throw new DocblockParseException( + $method_entry . ' is not a valid method: ' + . $e->getMessage(), + 0, + $e, + ); } if (!$method_tree instanceof MethodWithReturnTypeTree diff --git a/src/Psalm/Internal/Type/ParseTreeCreator.php b/src/Psalm/Internal/Type/ParseTreeCreator.php index 9449448a8ee..34502e118cb 100644 --- a/src/Psalm/Internal/Type/ParseTreeCreator.php +++ b/src/Psalm/Internal/Type/ParseTreeCreator.php @@ -780,8 +780,7 @@ private function handleValue(array $type_token): void $type_token[0], $new_parent, ); - } elseif ($type_token[0] !== 'array' - && $type_token[0][0] !== '\\' + } elseif ($type_token[0][0] !== '\\' && $this->current_leaf instanceof Root ) { $new_leaf = new MethodTree( diff --git a/tests/MagicMethodAnnotationTest.php b/tests/MagicMethodAnnotationTest.php index 9351ea511f5..197b9fc62b1 100644 --- a/tests/MagicMethodAnnotationTest.php +++ b/tests/MagicMethodAnnotationTest.php @@ -939,6 +939,14 @@ class D extends C {} '$e' => 'B', ], ], + 'arrayAsMethodName' => [ + 'code' => <<<'PHP' +