PHP: Parse Error on Disjunctive Normal Form Types (PHP 8.2 feature)

We are using SonarCloud with sonarsource/sonar-scanner-cli Docker Image for analyzing PHP files.
When using typed properties with Disjunctive Normal Form (introduced in PHP 8.2, see PHP: rfc:dnf_types), we get this error:

ERROR Unable to parse file [file:///path/ExampleClass.php] at line 4
ERROR Parse error at line 4 column 18:

Online PHP editor | output for c3IEO gives an example and shows that this parse error is valid for PHP versions below 8.2, but totally valid for PHP 8.2 and greater.

Additional infos: PHP: Type declarations - Manual

And as stated by PHP Static Code Analysis & Laravel Clean Code Programming Language, PHP versions from 8.0 to 8.3 should be fully supported.

Hi @stchrTIO

Thank you for the report, and welcome to the community!

I confirm the error. I created a ticket [SONARPHP-1533] - Jira to fix this issue.

Best
Marcin Stachniuk

1 Like