# Q: how specify PHP version? (not recognizing PHP 7.4 arrow functions)

**URL:** <https://community.sonarsource.com/t/q-how-specify-php-version-not-recognizing-php-7-4-arrow-functions/54116>\
**Category:** SonarQube Cloud\
**Tags:** php, sonarqube-cloud\
**Created:** [December 1, 2021, 11:08am UTC](https://community.sonarsource.com/t/q-how-specify-php-version-not-recognizing-php-7-4-arrow-functions/54116 "2021-12-01T11:08:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daryn](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/daryn/32/27953_2.png) [@daryn](https://community.sonarsource.com/u/daryn)\
**Post date:** [December 1, 2021, 11:08am UTC](https://community.sonarsource.com/t/q-how-specify-php-version-not-recognizing-php-7-4-arrow-functions/54116/1 "2021-12-01T11:08:57Z")

</div>

- SonarCloud
- PHP using the “Sonar way” Quality Profile

This php arrow function code:

```auto
$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](https://sonarcloud.io/organizations/accompany-io/rules?open=php%3AS3699&rule_key=php%3AS3699)
- I believe the code is correct PHP [arrow function syntax](https://www.php.net/manual/en/functions.arrow.php). `$func` is 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?](https://community.sonarsource.com/t/how-to-set-php-version/5323), 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?

Thanks

---

<div class="post-metadata">

**Author:** ![Karim\_El\_Ouerghemmi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/karim_el_ouerghemmi/32/12764_2.png) [@Karim\_El\_Ouerghemmi](https://community.sonarsource.com/u/Karim_El_Ouerghemmi)\
**Post date:** [December 1, 2021, 12:08pm UTC](https://community.sonarsource.com/t/q-how-specify-php-version-not-recognizing-php-7-4-arrow-functions/54116/2 "2021-12-01T12:08:53Z")

</div>

Hey @daryn,

This is indeed a false positive with that rules implementation. I did create [SONARPHP-1268](https://jira.sonarsource.com/browse/SONARPHP-1268) to track it. It is not really related to setting the right PHP version.

> [@daryn](#):
>
> **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?

There is no such mechanism currently in the PHP analyzer (which might change). The analyzer does parse PHP syntax up to the latest PHP version (8.1 with [the latest release](https://community.sonarsource.com/t/sonarcloud-can-scan-your-php-8-1-code/53965)). Sometimes, with the addition of new syntax, existing rules have to be adapted. This should have been done for `S3699` when arrow functions were introduced.

Thanks very much for reporting this!

Best,  
Karim.
