mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #134 - warn when docblock type is ill-formatted
This commit is contained in:
parent
77a44051c5
commit
42b435e23f
@ -143,6 +143,10 @@ class CommentChecker
|
||||
&& !strpos($line_parts[0], '::')
|
||||
&& $line_parts[0][0] !== '{'
|
||||
) {
|
||||
if ($line_parts[0][0] === '$' && $line_parts[0] !== '$this') {
|
||||
throw new DocblockParseException('Badly-formatted @param type');
|
||||
}
|
||||
|
||||
$info->return_type = $line_parts[0];
|
||||
$line_number = array_keys($return_specials)[0];
|
||||
|
||||
@ -176,6 +180,10 @@ class CommentChecker
|
||||
$line_parts[1] = substr($line_parts[1], 1);
|
||||
}
|
||||
|
||||
if ($line_parts[0][0] === '$' && $line_parts[0] !== '$this') {
|
||||
throw new DocblockParseException('Badly-formatted @param type');
|
||||
}
|
||||
|
||||
$line_parts[1] = preg_replace('/,$/', '', $line_parts[1]);
|
||||
|
||||
$info->params[] = [
|
||||
@ -290,6 +298,10 @@ class CommentChecker
|
||||
$line_parts[1] = substr($line_parts[1], 1);
|
||||
}
|
||||
|
||||
if ($line_parts[0][0] === '$' && $line_parts[0] !== '$this') {
|
||||
throw new DocblockParseException('Badly-formatted @param type');
|
||||
}
|
||||
|
||||
$line_parts[1] = preg_replace('/,$/', '', $line_parts[1]);
|
||||
|
||||
$info->properties[] = [
|
||||
|
@ -173,6 +173,16 @@ class AnnotationTest extends TestCase
|
||||
public function providerFileCheckerInvalidCodeParse()
|
||||
{
|
||||
return [
|
||||
'invalidReturn' => [
|
||||
'<?php
|
||||
interface I {
|
||||
/**
|
||||
* @return $thus
|
||||
*/
|
||||
public static function barBar();
|
||||
}',
|
||||
'error_message' => 'InvalidDocblock'
|
||||
],
|
||||
'deprecatedMethodWithCall' => [
|
||||
'<?php
|
||||
class Foo {
|
||||
|
Loading…
Reference in New Issue
Block a user