Regarding the formatting rule for PHP (php:S1808):
"Align all arguments in this list at column “xx”.
When you’re using named parameters in PHP this will complain about argument misalignment when the named parameter is actually aligned on the correct column. I hope this can be either configured or allowed in the future, because we use these everywhere.
As a side note, we’d love to see a rule to say that you should always be using named parameters when a function has more than X arguments.
// Triggers the code smell
$this->someFunction(
parameterA: $arg1,
parameterB: $arg2,
);
// Does not trigger the code smell
$this->someFunction(
$arg1,
$arg2,
);
// The "fix"
$this->someFunction(
parameter1:
$arg1,
parameter2:
$arg2,
)
I’m using SonarCloud, also using SonarLint 7.1.1 in PHPStorm.
Also using the GitHub Action (SonarSource/sonarcloud-github-action@master) with no significant config apart from source and coverage report locations.
Thank you for your report. Indeed, this is a false positive, and we should not raise an issue. It seems that we are not correctly handling named arguments. I’ve created a ticket to fix this. Thanks for the contribution.
This issue makes sonar trigger errors when using PHP Attributes for Doctrine and/or OpenApi.
Even if I agree with Benjamin named argument are great and a rule such as he mention would be useful, named argument is not mandatory.
Except that with PHP Attributes it’s mandatory, is there a plan for this issue
Hello, yes indeed. It’s fixed and released. It will be available in the next SonarCloud deployment as well as in the next SonarLint and SonarQube releases.