New PHP code smell rule proposal: discourage use of parentheses in return()


PHP: return - Manual says:

since return is a language construct and not a function, the parentheses surrounding its argument are not required and their use is discouraged.

There does not seem to be a rule for this in SonarQube (I am using the latest LTS community edition).

Would it be possible to update the Sonar Way PHP rules to include a code smell warning if return($foo); is used instead of return $foo; ?

Hi @mig5

and welcome to the community. Sounds like a good rule idea. I searched through our existing rules and found rule RSPEC-2041. I can imagine replacing this rule and creating a new rule that applies to all language constructs. Here you can find the dedicated ticket for this rule idea. Thank you for your contribution.


1 Like