Configuration of PHPStan with Sonar Cloud

Hello All,

I faced a problem when trying to configure the PHPStan report as a JSON file.

Sonar Cloud is retrieve the file but it’s can’t analyze it.

I got this issue as in image

Failed to resolve 1305 file path(s) in PHPStan phpstan_report.json report. No issues imported related to file(s): C:\laragon\www\XYZ\Override\haruncpi\laravel-id-generator\src\IdGenerator.php;C:\laragon\www\XYZ\Override\haruncpi\laravel-id-generator\src\IdGeneratorServiceProvider.php;C:\laragon\www\XYZ\Override\haruncpi\laravel-id-generator\tests\Unit\IdGenerateTest.php;C:\laragon\www\XYZ\app\Classes\Chan

I remove the absolute path from phpstan_report.json and I got a smaller number of errors

Hey @bsaqqa,

Welcome to the community!

Indeed, making sure that the paths are the same as the sonar scanner will see them is the first step. This is what you did fix already.

The second problem is something we did miss when implementing the import mechanism. I did create the ticket SONARPHP-1262 to keep track of this.
Until we handle the ticket, the only solution I see is to do a search-replace over the report and remove all strings matching \s\(in context of [^)]*\).

Thanks very much for making us aware of this!

Best,
Karim.

Hi @Karim_El_Ouerghemmi ,

Thanks for your reply.
We wait for you to solve it.

Regards.

Hey @bsaqqa

SONARPHP-1262 was deployed on production on Monday. Can you confirm it’s fixed on your end?

1 Like