llaville / php-compatinfo

Library that find out the minimum version and the extensions required for a piece of code to run
https://llaville.github.io/php-compatinfo/7.1/
Other
371 stars 21 forks source link

Error reported with phpCompatInfo version 7.1.3 and DB Version 6.4.2 #373

Closed MocioF closed 5 months ago

MocioF commented 5 months ago

With PHP 8.1.26 while analyzing a codebase sent a warning:

74%PHP Warning: Undefined array key "Strict_Types" in [...]vendor/bartlett/php-compatinfo/src/Application/Sniffs/ControlStructures/DeclareSniff.php on line 66 And then it ended with error: [ERROR] Cannot analyse data source "[...]" for following reason(s)

llaville commented 5 months ago

Please provide source code you've analyzed ! I can't find any issue, if I can't reproduce it with contextual data.

MocioF commented 5 months ago

It's the code in my repo No-unsafe-inline/. I analyzed the code including the vendor dir (built with dev dependencies) and excluding node_modules. I will check if the issue is present while installing composer dependencies with --no-dev (In this second scenario I didn't see the error using the previous version). I will update this issue with more info in next days. Thanks for your work and your attention.

llaville commented 5 months ago

Checked an see your problem. You've not analyzed your source code, but all code (source + vendors). And in your situation (squizlabs/php_codesniffer 3.9.0 is installed) with a test file that have declare (strict_types) with case sensitive declaration. See https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.3.inc#L3

I don't consider it's a major issue for CompatInfo, even if we may fix it easily, because I don't think that PHP developers will use in real condition this standard code format !

MocioF commented 5 months ago

ok @llaville , thanks for your help. I think you are right because PHPCS is a dev tool, but I even think that it's normal to use your tool including vendor dir (even if in a build with --no-dev) because vendor dir is part of the deployed package and we need to analyze it to see what extensions and PHP versions are needed to run the software under analysis.