Context:
- Fresh install via composer on my local machine (MacOS) and CircleCI (Ubuntu)
- Occurs with: master and develop branch, as well as 0.13 tag. Fixed when rolling back to 0.12 ( composer also rolls-back PHPCS to 2.9.1).
- How to reproduce:
composer install --no-interaction
vendor/bin/phpcs ./
Error:
PHP Fatal error: Class 'WordPress\AbstractArrayAssignmentRestrictionsSniff' not found in /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php on line 30
PHP Stack trace:
PHP 1. {main}() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/bin/phpcs:0
PHP 2. PHP_CodeSniffer\Runner->runPHPCS() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/bin/phpcs:18
PHP 3. PHP_CodeSniffer\Runner->init() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Runner.php:70
PHP 4. PHP_CodeSniffer\Ruleset->__construct() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Runner.php:294
PHP 5. PHP_CodeSniffer\Ruleset->registerSniffs() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Ruleset.php:206
PHP 6. PHP_CodeSniffer\Autoload::loadFile() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1094
PHP 7. include() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/autoload.php:167
Fatal error: Class 'WordPress\AbstractArrayAssignmentRestrictionsSniff' not found in /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php on line 30
Call Stack:
0.0004 353304 1. {main}() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/bin/phpcs:0
0.0050 570272 2. PHP_CodeSniffer\Runner->runPHPCS() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/bin/phpcs:18
0.0190 871608 3. PHP_CodeSniffer\Runner->init() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Runner.php:70
0.0261 1145408 4. PHP_CodeSniffer\Ruleset->__construct() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Runner.php:294
0.1185 1611952 5. PHP_CodeSniffer\Ruleset->registerSniffs() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Ruleset.php:206
0.1185 1612008 6. PHP_CodeSniffer\Autoload::loadFile() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1094
0.1187 1630416 7. include('/Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php') /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/autoload.php:167
plugin-disable-sidebar $ vendor/bin/phpcs ./
PHP Fatal error: Class 'WordPress\AbstractArrayAssignmentRestrictionsSniff' not found in /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php on line 30
PHP Stack trace:
PHP 1. {main}() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/bin/phpcs:0
PHP 2. PHP_CodeSniffer\Runner->runPHPCS() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/bin/phpcs:18
PHP 3. PHP_CodeSniffer\Runner->init() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Runner.php:70
PHP 4. PHP_CodeSniffer\Ruleset->__construct() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Runner.php:294
PHP 5. PHP_CodeSniffer\Ruleset->registerSniffs() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Ruleset.php:206
PHP 6. PHP_CodeSniffer\Autoload::loadFile() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1094
PHP 7. include() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/autoload.php:167
Fatal error: Class 'WordPress\AbstractArrayAssignmentRestrictionsSniff' not found in /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php on line 30
Call Stack:
0.0003 353336 1. {main}() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/bin/phpcs:0
0.0041 570304 2. PHP_CodeSniffer\Runner->runPHPCS() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/bin/phpcs:18
0.0197 925472 3. PHP_CodeSniffer\Runner->init() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Runner.php:70
0.0233 1146264 4. PHP_CodeSniffer\Ruleset->__construct() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Runner.php:294
0.1043 1612432 5. PHP_CodeSniffer\Ruleset->registerSniffs() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Ruleset.php:206
0.1043 1612488 6. PHP_CodeSniffer\Autoload::loadFile() /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1094
0.1045 1630896 7. include('/Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php') /Users/guillaumemolter/Dev/vvv/www/sites/htdocs/wp-content/plugins/plugin-disable-sidebar/vendor/squizlabs/php_codesniffer/autoload.php:167
FYI: a patch for this part of the issue has just been merged upstream, so should be included in the PHPCS 3.1.0 release.
@evilebottnawi
In this thread we’ve come across two different issues which are both upstream PHPCS issues to solve:
autoloaddirective not being respected if a custom ruleset only includes a category, not a complete standard: https://github.com/squizlabs/PHP_CodeSniffer/issues/1582installed_pathsis set via the ruleset and there is noinstalled_pathsset in thePHPCodeSniffer.conffile: https://github.com/squizlabs/PHP_CodeSniffer/issues/1591Both issues still need to be fixed upstream.
The first issue can be solved locally by either - as you did - including the autoloader yourself or by including a complete ruleset and excluding the categories you don’t want.
The second issue can be solved by using the DealerDirect Composer plugin, but is also (temporarily) patched via
0.13.1.There is nothing more we can do in WPCS in this respect.
@jrfnl Ok thanks for the explanation. I’ve implemented the change to our ruleset. It makes sense when you think about it for more than 10 seconds 😃. However this didn’t fix the issue. How would I fix the issue via our ruleset? I can also keep using 0.12 for now.
Re custom prop: We welcome anything that can make our code more standard, future-proof and secure. I cannot stress enough how much our code base quality has improved since we have decided to strictly enforce WPCS using PHPCS and your tool. So thank you for all the good work and dedication.