1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

Merge pull request #6552 from orklah/manipulator

This commit is contained in:
Bruce Weirdan 2021-09-30 21:54:55 +03:00 committed by GitHub
commit 377d3bddf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -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)

View File

@ -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,
],
];
}
}