# Visibility keyword in class constructor causes a parse error

**URL:** <https://community.sonarsource.com/t/visibility-keyword-in-class-constructor-causes-a-parse-error/63369>\
**Category:** SonarQube Server / Community Build\
**Tags:** php8\
**Created:** [May 17, 2022, 7:59am UTC](https://community.sonarsource.com/t/visibility-keyword-in-class-constructor-causes-a-parse-error/63369 "2022-05-17T07:59:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Melka](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/martin_melka/32/33439_2.png) [@Martin\_Melka](https://community.sonarsource.com/u/Martin_Melka)\
**Post date:** [May 17, 2022, 7:59am UTC](https://community.sonarsource.com/t/visibility-keyword-in-class-constructor-causes-a-parse-error/63369/1 "2022-05-17T07:59:28Z")

</div>

Hi, according to the following [ERROR: Unable to parse file PHP ENUMs](https://community.sonarsource.com/t/error-unable-to-parse-file-php-enums/56856) SonarQube 9.3 should support PHP 8.1. I have upgraded but still are encountering issues.

Using SonarQube Version 9.4 (build 54424) and [sonar-scanner-cli 4.7.0](https://hub.docker.com/r/sonarsource/sonar-scanner-cli/tags).

The error report states:

```auto
ERROR: Unable to parse file [file:///builds/xxxx/Configuration/Internationalization/I18nConfig.php] at line 12
ERROR: Parse error at line 12 column 42:
 2: declare(strict_types=1);
 3: 
 4: namespace XX\XX\Configuration\Internationalization;
 5: 
 6: class I18nConfig
 7: {
 8: /**
 9: * @param string $defaultLocale - Default locale of the installation
10: * @param array<string> $supportedLocales - Supported locales of the installation
11: */
12: public function __construct(readonly public string $defaultLocale, readonly public array $supportedLocales)
                                             ^
13: {
14: }
15: }
16: 

```

Seems that the `readonly` keyword is tripping SonarQube up. Is this a bug or do I need to upgrade _something_?

Thanks!

---

<div class="post-metadata">

**Author:** ![Nils\_Werner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nils_werner/32/14437_2.png) [@Nils\_Werner](https://community.sonarsource.com/u/Nils_Werner)\
**Post date:** [June 3, 2022, 2:01pm UTC](https://community.sonarsource.com/t/visibility-keyword-in-class-constructor-causes-a-parse-error/63369/4 "2022-06-03T14:01:50Z")

</div>

Hello @Martin_Melka,

Sorry for the late response. Indeed, there is a parsing error in our parser. The problem is the order of characteristic keywords of the promoted properties. The code `public readonly string $defaultLocale` will not lead to a parsing error. However, we have to adapt our parser because different orders are also allowed. I’ve created a [ticket](https://jira.sonarsource.com/browse/SONARPHP-1300) to tackle this problem. Thank you for raising this point.

Best,
