- Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Quite apart from #1452, I'm still having trouble with the autoloader not finding files.
I'm testing on a git checkout of PHPCS master
on PHP 5.6.23 with a local work-in-progress branch for the PHPCompatibility standard.
Issue 1 (PR submitted)
If I run just the one sniff against a set of files, no sniffs are being registered. This should be fixed by #1451.
phpcs ./test.inc --standard=PHPCompatibility --sniffs=PHPCompatibility.PHP.NewClasses
Issue 2 (PR submitted)
If I run the complete standard against a set of files, the sniffs are being registered, but the first two are misidentified causing errors along the lines of Fatal error: Call to undefined method PHP_CodeSniffer\Util\Tokens::register()
. This should be fixed by #1452.
phpcs ./test.inc --standard=PHPCompatibility
Issue 3 (not yet resolved)
Next, I'm trying to run the standard via a custom ruleset:
phpcs -vv ./test.inc --standard=phpcs.xml
Custom ruleset (minimal example):
<?xml version="1.0"?> <ruleset name="PHPCS Coding Standards for PHPCompatibility"> <arg value="sp"/> <arg name="extensions" value="php"/> <!-- Exclude test case code. --> <exclude-pattern>/Tests/sniff-examples/*</exclude-pattern> <config name="testVersion" value="5.3-99.0"/> <rule ref="PHPCompatibility"/> <rule ref="PSR2"/> </ruleset>
I can see that the sniffs are being registered, but now it's not auto-loading the base sniff:
Fatal error: Class 'PHPCompatibility\Sniff' not found in \PHPCompatibility\PHPCompatibility\Sniffs\PHP\CaseSensitiveKeywordsSniff.php on line 29 Call Stack: 0.0010 124464 1. {main}() PHP_CodeSniffer\bin\phpcs:0 0.0050 288584 2. PHP_CodeSniffer\Runner->runPHPCS() PHP_CodeSniffer\bin\phpcs:18 0.2790 711312 3. PHP_CodeSniffer\Runner->init() PHP_CodeSniffer\src\Runner.php:67 0.2900 978352 4. PHP_CodeSniffer\Ruleset->__construct() PHP_CodeSniffer\src\Runner.php:273 1.4431 1012328 5. PHP_CodeSniffer\Ruleset->registerSniffs() PHP_CodeSniffer\src\Ruleset.php:222 1.4441 1018064 6. PHP_CodeSniffer\Autoload::loadFile() PHP_CodeSniffer\src\Ruleset.php:1089 1.4481 1045680 7. include('I:\correct\path\to\PHPCompatibility\PHPCompatibility\Sniffs\PHP\CaseSensitiveKeywordsSniff.php') PHP_CodeSniffer\autoload.php:156
The directory structure is still the same and the sniffs are properly namespaced etc (well, otherwise the previous two runs wouldn't work either obviously).
Let me know if you need more information.