Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow array as magic method name #9391

Merged
merged 1 commit into from Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Psalm/Internal/Type/ParseTreeCreator.php
Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions tests/MagicMethodAnnotationTest.php
Expand Up @@ -939,6 +939,14 @@ class D extends C {}
'$e' => 'B',
],
],
'arrayAsMethodName' => [
'code' => <<<'PHP'
<?php
/** @method static void array() */
class C {}
//C::array();
PHP,
],
];
}

Expand Down