- PHP using the “Sonar way” Quality Profile
This php arrow function code:
$func = fn ($param) => $this->myVoidFunc($param);
Is being flagged for rule “The output of functions that don’t return anything should not be used”
- Rule: php:S3699 link
- I believe the code is correct PHP arrow function syntax.
$funcis not being assigned the result of a function call, it is being assigned the function itself.
I don’t see any issue reports in the community about this, so perhaps I’m missing something. Arrow functions were introduced in PHP 7.4, that seems the most likely cause. I have looked and not found documentation about how SonarCloud determines which PHP version to use for the analysis. This question was asked 3 years ago, How to set PHP version?, but the thread does not contain the answer to the question.
Q: What does SonarCloud use to determine which PHP version to use in its analysis?
… and specifically, how can I ensure it uses PHP 7.4?