mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #2441 - add error when @template type is missing
This commit is contained in:
parent
e3d108ebd9
commit
d6a731be73
@ -559,6 +559,10 @@ class CommentAnalyzer
|
||||
|
||||
$template_name = array_shift($template_type);
|
||||
|
||||
if (!$template_name) {
|
||||
throw new IncorrectDocblockException('Empty @template tag');
|
||||
}
|
||||
|
||||
if (count($template_type) > 1
|
||||
&& in_array(strtolower($template_type[0]), ['as', 'super', 'of'], true)
|
||||
) {
|
||||
@ -731,6 +735,10 @@ class CommentAnalyzer
|
||||
|
||||
$template_name = array_shift($template_type);
|
||||
|
||||
if (!$template_name) {
|
||||
throw new IncorrectDocblockException('Empty @template tag');
|
||||
}
|
||||
|
||||
if (count($template_type) > 1
|
||||
&& in_array(strtolower($template_type[0]), ['as', 'super', 'of'], true)
|
||||
) {
|
||||
@ -764,6 +772,10 @@ class CommentAnalyzer
|
||||
|
||||
$template_name = array_shift($template_type);
|
||||
|
||||
if (!$template_name) {
|
||||
throw new IncorrectDocblockException('Empty @template-covariant tag');
|
||||
}
|
||||
|
||||
if (count($template_type) > 1
|
||||
&& in_array(strtolower($template_type[0]), ['as', 'super', 'of'], true)
|
||||
) {
|
||||
|
@ -1277,6 +1277,12 @@ class FunctionTemplateTest extends TestCase
|
||||
apply(new Printer(), new B());',
|
||||
'error_message' => 'InvalidArgument'
|
||||
],
|
||||
'invalidTemplateDocblock' => [
|
||||
'<?php
|
||||
/** @template */
|
||||
function f():void {}',
|
||||
'error_message' => 'MissingDocblockType'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user