inspector-php icon indicating copy to clipboard operation
inspector-php copied to clipboard

ci: add Static Analysis via PHPStan

Open owenvoke opened this issue 3 years ago • 3 comments

This adds static analysis of the package via PHPStan. 👍🏻

I've currently baselined the existing issues, and this should probably be worked through to reduce this so that the baseline can be removed. 👌🏻 Some of the things like the curl_* function issues at the bottom can't easily be removed as CurlHandle isn't available on PHP 7.x, so unless PHP 7 is dropped, this probably can't be addressed.

However, it has drawn attention to issues like dynamically-declared properties (which are removed in PHP 8.2).

owenvoke avatar Feb 24 '23 10:02 owenvoke

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Feb 24 '23 10:02 sonarqubecloud[bot]

Just to be sure let me ask you: The baselined issues exist because Transaction, Segment, and Error are array objects to which properties are dynamically added. PHPStan doesn't recognize it and see a lot of undefined properties?

ilvalerione avatar Mar 01 '23 16:03 ilvalerione

Yes, as far as I can tell, that is correct. 🤔 I guess this should be possible to resolve with generics, or by specifying the properties as docblocks. 🤷🏻 Or adding the properties so that they aren't within an array.

owenvoke avatar Mar 01 '23 17:03 owenvoke