diff --git a/build/psalm/AttributeNamedParameters.php b/build/psalm/AttributeNamedParameters.php new file mode 100644 index 00000000000..0b34cf3cf22 --- /dev/null +++ b/build/psalm/AttributeNamedParameters.php @@ -0,0 +1,53 @@ +getStmt(); + $statementsSource = $event->getStatementsSource(); + + foreach ($stmt->attrGroups as $attrGroup) { + foreach ($attrGroup->attrs as $attr) { + self::checkAttribute($attr, $statementsSource); + } + } + + foreach ($stmt->getMethods() as $method) { + foreach ($method->attrGroups as $attrGroup) { + foreach ($attrGroup->attrs as $attr) { + self::checkAttribute($attr, $statementsSource); + } + } + } + } + + private static function checkAttribute(Attribute $stmt, FileSource $statementsSource): void { + if ($stmt->name->getLast() === 'Attribute') { + return; + } + + foreach ($stmt->args as $arg) { + if ($arg->name === null) { + IssueBuffer::maybeAdd( + new InvalidDocblock( + 'Attribute arguments must be named.', + new CodeLocation($statementsSource, $stmt) + ) + ); + } + } + } +} diff --git a/psalm.xml b/psalm.xml index f2aed4b382b..05ea0ef20bc 100644 --- a/psalm.xml +++ b/psalm.xml @@ -16,6 +16,7 @@ > +