Skip to content

Commit

Permalink
Merge pull request #9391 from weirdan/allow-array-as-magic-method-name
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Feb 24, 2023
2 parents c0d5d21 + 5f59f07 commit 5f765a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
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

0 comments on commit 5f765a9

Please sign in to comment.