1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #3721 - prevent crash on empty @method

This commit is contained in:
Brown 2020-07-01 09:00:33 -04:00
parent cceacde01d
commit 4c368da75e
2 changed files with 12 additions and 0 deletions

View File

@ -1023,6 +1023,10 @@ class CommentAnalyzer
// replace array bracket contents // replace array bracket contents
$method_entry = preg_replace('/\[([0-9a-zA-Z_\'\" ]+,)*([0-9a-zA-Z_\'\" ]+)\]/', '[]', $method_entry); $method_entry = preg_replace('/\[([0-9a-zA-Z_\'\" ]+,)*([0-9a-zA-Z_\'\" ]+)\]/', '[]', $method_entry);
if (!$method_entry) {
throw new DocblockParseException('No @method entry specified');
}
try { try {
$parse_tree_creator = new ParseTreeCreator( $parse_tree_creator = new ParseTreeCreator(
TypeTokenizer::getFullyQualifiedTokens( TypeTokenizer::getFullyQualifiedTokens(

View File

@ -838,6 +838,14 @@ class MagicMethodAnnotationTest extends TestCase
$b->foo();', $b->foo();',
'error_message' => 'UndefinedMagicMethod', 'error_message' => 'UndefinedMagicMethod',
], ],
'lonelyMethod' => [
'<?php
/**
* @method
*/
class C {}',
'error_message' => 'InvalidDocblock',
],
]; ];
} }