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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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