diff --git a/src/Psalm/Internal/Analyzer/AttributeAnalyzer.php b/src/Psalm/Internal/Analyzer/AttributeAnalyzer.php index d32524cc5..95cf8b0bc 100644 --- a/src/Psalm/Internal/Analyzer/AttributeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/AttributeAnalyzer.php @@ -63,25 +63,27 @@ class AttributeAnalyzer return; } + $type_expr = \Psalm\Internal\Stubs\Generator\StubsGenerator::getExpressionFromType( + $type + ); + + $arg_attributes = [ + 'startFilePos' => $storage_arg->location->raw_file_start, + 'endFilePos' => $storage_arg->location->raw_file_end, + 'startLine' => $storage_arg->location->raw_line_number + ]; + + $type_expr->setAttributes($arg_attributes); + $node_args[] = new PhpParser\Node\Arg( - \Psalm\Internal\Stubs\Generator\StubsGenerator::getExpressionFromType( - $type - ), + $type_expr, false, false, - [ - 'startFilePos' => $storage_arg->location->raw_file_start, - 'endFilePos' => $storage_arg->location->raw_file_end, - 'startLine' => $storage_arg->location->raw_line_number - ], + $arg_attributes, $storage_arg->name ? new PhpParser\Node\Identifier( $storage_arg->name, - [ - 'startFilePos' => $storage_arg->location->raw_file_start, - 'endFilePos' => $storage_arg->location->raw_file_end, - 'startLine' => $storage_arg->location->raw_line_number - ] + $arg_attributes ) : null ); diff --git a/tests/AttributeTest.php b/tests/AttributeTest.php index c68d0e9b7..be08806bd 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -159,6 +159,23 @@ class AttributeTest extends TestCase false, '8.0' ], + 'invalidArgument' => [ + ' 'InvalidScalarArgument', + [], + false, + '8.0' + ], 'classAttributeUsedOnFunction' => [ '