mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #1730 - parse @param * $foo
properly
This commit is contained in:
parent
523ad144a2
commit
20422cf223
@ -78,7 +78,10 @@ class CommentAnalyzer
|
||||
|
||||
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
||||
|
||||
if ($line_parts[0][0] === '$' && $line_parts[0] !== '$this') {
|
||||
if ($line_parts[0] === ''
|
||||
|| ($line_parts[0][0] === '$'
|
||||
&& !preg_match('/^\$this(\||$)/', $line_parts[0]))
|
||||
) {
|
||||
throw new IncorrectDocblockException('Misplaced variable');
|
||||
}
|
||||
|
||||
@ -304,7 +307,10 @@ class CommentAnalyzer
|
||||
|
||||
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
||||
|
||||
if ($line_parts[0][0] === '$' && !preg_match('/^\$this(\||$)/', $line_parts[0])) {
|
||||
if ($line_parts[0] === ''
|
||||
|| ($line_parts[0][0] === '$'
|
||||
&& !preg_match('/^\$this(\||$)/', $line_parts[0]))
|
||||
) {
|
||||
throw new IncorrectDocblockException('Misplaced variable');
|
||||
}
|
||||
|
||||
@ -340,14 +346,17 @@ class CommentAnalyzer
|
||||
$line_parts[1] = substr($line_parts[1], 1);
|
||||
}
|
||||
|
||||
if ($line_parts[0][0] === '$' && !preg_match('/^\$this(\||$)/', $line_parts[0])) {
|
||||
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
||||
|
||||
if ($line_parts[0] === ''
|
||||
|| ($line_parts[0][0] === '$'
|
||||
&& !preg_match('/^\$this(\||$)/', $line_parts[0]))
|
||||
) {
|
||||
throw new IncorrectDocblockException('Misplaced variable');
|
||||
}
|
||||
|
||||
$line_parts[1] = preg_replace('/,$/', '', $line_parts[1]);
|
||||
|
||||
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
||||
|
||||
$info->params_out[] = [
|
||||
'name' => trim($line_parts[1]),
|
||||
'type' => str_replace("\n", '', $line_parts[0]),
|
||||
|
@ -1515,6 +1515,14 @@ class AnnotationTest extends TestCase
|
||||
function foo() {}',
|
||||
'error_message' => 'InvalidReturnType - src' . DIRECTORY_SEPARATOR . 'somefile.php:2:33',
|
||||
],
|
||||
'invalidParamDocblockAsterisk' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param * $reference
|
||||
*/
|
||||
function f($reference) {}',
|
||||
'error_message' => 'MissingDocblockType'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user