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

Sniff `AttributeSniff` raise `php.min` too much #342

Closed llaville closed 2 years ago

llaville commented 2 years ago

Bug report category

Diagnose

Output of `diagnose` command ``` Requirements Checker ==================== > Running PHP CompatInfo with PHP 7.4.27 on Linux 4.19.128-microsoft-standard > PHP is using the following php.ini file: WARNING: No configuration file (php.ini) used by PHP! > Checking PHP CompatInfo requirements: [x] PHP version must be at least 7.4.0 [x] pdo_sqlite extension must be available [x] Check if source "/home/devilbox/.cache/bartlett/compatinfo-db.sqlite" can be reached [x] Check if tables exists in database [x] Check if platforms are available in database ? Environment > [APP_ENV] prod > [APP_DATABASE_URL] sqlite:////home/devilbox/.cache/bartlett/compatinfo-db.sqlite > [APP_PROXY_DIR] /tmp/bartlett/php-compatinfo-db/3.19.x-dev@88c021d/proxies > [APP_VENDOR_DIR] phar:///shared/backups/php/phpcompatinfo-6.2-dev.phar/vendor > [APP_CACHE_DIR] /home/devilbox/.cache/bartlett > [APP_HOME_DIR] /home/devilbox [OK] Your system is ready to run the application. ! [NOTE] phpCompatInfo version 6.2.x-dev@bb9cd8d DB version 3.19.x-dev@88c021d ```

Summary

When we scan source code that use the new PHP Attributes feature, the PHP min requirements at end of analysis is too much.

Expected behaviour

PHP min expected raised on right value.

Actual behaviour

Using this source code: git clone https://github.com/phar-io/manifest

Especially scan this file : https://github.com/phar-io/manifest/blob/2.0.3/src/xml/ElementCollection.php#L27-L28

Using this command: phpcompatinfo-6.2-dev.phar ana:run src/xml/ElementCollection.php --no-ansi -v

Output of `analyser:run` command ``` Compatibility Analyser ====================== Data Source Analysed -------------------- Directories 1 + /shared/backups/github/manifest/src/xml Files 1 + /shared/backups/github/manifest/src/xml/ElementCollection.php Errors 0 Extensions Analysis ------------------- Extension REF EXT min/Max PHP min/Max core core 5.3.0 5.3.0 dom dom 5.0.0 7.1.0 standard standard 4.0.0 4.0.0 Total [3] 7.1.0 Namespaces Analysis ------------------- Namespace REF EXT min/Max PHP min/Max PharIo\Manifest core 5.3.0 8.0.0alpha1 Total [1] 8.0.0alpha1 Interfaces Analysis ------------------- Interface REF EXT min/Max PHP min/Max Iterator core 5.3.0 5.3.0 Total [1] 5.3.0 ! [NOTE] No trait found Classes Analysis ---------------- Class REF EXT min/Max PHP min/Max DOMNodeList dom 5.0.0 5.0.0 PharIo\Manifest\ElementCollection core 5.3.0 8.0.0alpha1 function __construct dom 5.0.0 5.0.0 function current user 8.0.0alpha1 function next user 7.1.0 function key user 7.0.0alpha1 function valid standard 4.0.0 7.0.0alpha1 function rewind user 7.1.0 function getCurrentElement user 7.0.0alpha1 function importNodes core 5.0.0 7.1.0 U PharIo\Manifest\ElementCollectionException user 5.3.0 Total [3] 8.0.0alpha1 Enumerations Analysis --------------------- Enumeration REF EXT min/Max PHP min/Max DOMNodeList dom 5.0.0 5.0.0 Total [1] 5.0.0 ! [NOTE] No generator found Functions Analysis ------------------ Function REF EXT min/Max PHP min/Max count standard 4.0.0 4.0.0 get_class core 4.0.0 4.0.0 sprintf standard 4.0.0 4.0.0 Total [3] 4.0.0 ! [NOTE] No constant found ! [NOTE] No condition found [OK] Requires PHP 8.0.0alpha1 (min) // Produced by console_reporter ```
llaville commented 2 years ago

Related to recent change by #335