-
-
Notifications
You must be signed in to change notification settings - Fork 94
Description
This is a follow-up to squizlabs/PHP_CodeSniffer#3754. See also #1388.
The lists of PHP extensions in composer.json's "require" and "suggest" sections are incomplete. Running maglnet/composer-require-checker as described in squizlabs/PHP_CodeSniffer#3754 on this codebase (as at 8b1c267) yields the following issues (and a long list of PHP_CodeSniffer-internal T_* constants).
ComposerRequireChecker 4.0.1-111-g8b1c26745-dev
The following unknown symbols were found:
+-------------------------------------------------------+--------------------+
| unknown symbol | guessed dependency |
+-------------------------------------------------------+--------------------+
| Composer\Autoload\ClassLoader | |
| PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase | |
| PHP_CodeSniffer\Tests\ConfigDouble | |
| PHP_CODESNIFFER_VERBOSITY | |
| PHP_CODESNIFFER_CBF | |
| iconv_strlen | ext-iconv |
| libxml_use_internal_errors | ext-libxml |
| libxml_get_errors | ext-libxml |
| libxml_clear_errors | ext-libxml |
| json_encode | ext-json |
| iconv | ext-iconv |
| DOMElement | ext-dom |
| DOMDocument | ext-dom |
| DOMNode | ext-dom |
| json_decode | ext-json |
| posix_isatty | ext-posix |
| pcntl_fork | ext-pcntl |
| pcntl_waitpid | ext-pcntl |
| pcntl_wexitstatus | ext-pcntl |
+-------------------------------------------------------+--------------------+
✅ \Composer\Autoload\ClassLoader
No action required here.
The use of this class is wrapped in suitable safeguarding code.
✅ PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase and PHP_CodeSniffer\Tests\ConfigDouble
No action required here.
These show up due to the way that I wrote the temporary 'autoload' section within composer.json and can safely be ignored.
This is a feature of the filesystem layout, having tests for each standard within the src/ directory.
✅ PHP_CODESNIFFER_VERBOSITY and PHP_CODESNIFFER_CBF
No action required here.
These are internal PHP_CodeSniffer constants which are always defined in the entrypoints used to run PHP_CodeSniffer.
Similarly, there is a long list of T_* constants which showed up in the tool output, which I have validated and removed before opening this issue.
🔲 ext-dom
This extension is used within the "generator" feature, and is used by all three generators (HTML, Markdown, Text).
While this extension is enabled by default within PHP, it is possible to disable it at compile time.
Actions required:
- Add a check to the start-up code. If a generator has been requested, and the extension is not available: throw some kind of error with a suitable message to the user.
- Update the wiki to show that this extension is required when using the generator feature.
🔲 ext-iconv
Actions required:
- Create a new way for reports to declare what extensions they need.
- Add a new constant to the
Reportinterface (with a default value, thus making this feature optional). Reports will use this constant to declare what PHP extensions they require in order to operate properly. - Add a check to the start-up code. For each report that has been requested: loop through all of the PHP extensions that it declares are necessary and assert that these are loaded. If any required PHP extensions are not present, throw some kind of error with a suitable message to the user.
- Add a new constant to the
- Add
iconvto the list of "required extensions" for the 'checkstyle' report. - Add
iconvto the list of "required extensions" for the 'junit' report. - Add
iconvto the list of "required extensions" for the 'xml' report. - Update the wiki to show that this extension is required when using the these reports.
🔲 ext-json
This extension is used without suitable checks in the 'json' report and the cache feature.
While this extension is enabled by default within PHP, it is possible to disable it at compile time for PHP versions below 8.0.
(From PHP 8.0 and above, this extension can no longer be disabled.)
Actions required:
- Add
jsonto the list of "required extensions" for the 'json' report. (See above for details of this new "required extensions" list.) - Add a check to the start-up code. If the cache feature was requested, and the extension is not available: disable the cache feature, warn the user that the cache feature has been disabled with a suitable message, and proceed with the run.
- Be sure to include a code comment reminding us that this check can be removed when we have a minimum PHP version of 8.0+.
- Update the wiki to show that this extension is required when using the cache feature.
- Update the wiki to show that this extension is required when using the 'json' report.
🔲 ext-libxml
This extension is a requirement of the SimpleXML extension which we already declare a depenency on.
While this extension is enabled by default within PHP, it is possible to disable it at compile time.
Actions required:
- Add
ext-libxmlto the "require" section ofcomposer.json. - Add
libxmlto the list of required extensions inrequirements.phpand its associated tests.
🔲 ext-pcntl
This extension is not currently available on Windows. This extension powers the "parallel" feature.
We already detect the existence of this extension and silently disable the parallel feature. I have discussed this with @jrfnl and we have agreed that this "automatic disable" should remain silent.
Actions required:
- Add a debug message to show that the parallel feature was silently disabled due to the absense of this extension.
- Update the wiki to show that this extension is required when using the parallel feature.
✅ ext-posix
No action required here.
This is used in exactly one place within the codebase (\PHP_CodeSniffer\Util\Common::isStdinATTY()). It is wrapped in a suitable check, and the code safely falls back to other methods to detect if the output will be going to a terminal or not.