mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
offset the starting position of the function in case of attributes
This commit is contained in:
parent
afbda6d0f6
commit
5a99c9be94
@ -123,6 +123,14 @@ class FunctionDocblockManipulator
|
||||
$this->docblock_end = $function_start = (int)$stmt->getAttribute('startFilePos');
|
||||
$function_end = (int)$stmt->getAttribute('endFilePos');
|
||||
|
||||
$attributes = $stmt->getAttrGroups();
|
||||
foreach ($attributes as $attribute) {
|
||||
// if we have attribute groups, we need to consider that the function starts after them
|
||||
if ((int) $attribute->getAttribute('endFilePos') > $function_start) {
|
||||
$function_start = (int) $attribute->getAttribute('endFilePos');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($stmt->params as $param) {
|
||||
if ($param->var instanceof PhpParser\Node\Expr\Variable
|
||||
&& \is_string($param->var->name)
|
||||
|
@ -1088,6 +1088,32 @@ class MissingReturnTypeTest extends FileManipulationTestCase
|
||||
false,
|
||||
true,
|
||||
],
|
||||
'WithAttributes' => [
|
||||
'<?php
|
||||
|
||||
class A
|
||||
{
|
||||
#[Foo()]
|
||||
public function bar()
|
||||
{
|
||||
}
|
||||
}
|
||||
',
|
||||
'<?php
|
||||
|
||||
class A
|
||||
{
|
||||
#[Foo()]
|
||||
public function bar(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
',
|
||||
'7.1',
|
||||
['MissingReturnType'],
|
||||
true,
|
||||
true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user