PHPCompatibility / PHPCompatibility

PHP Compatibility check for PHP_CodeSniffer

Home Page:http://techblog.wimgodden.be/tag/codesniffer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation via git does not work.

AphidGit opened this issue · comments

Bug Description

Given the following reproduction Scenario

$ mkdir /usr/src/phpSniffer
$ wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
$ cd /usr/src/phpSniffer
$ git clone https://github.com/PHPCompatibility/PHPCompatibility
$ phpcs --config-set installed_paths /usr/src/phpSniffer/PHPCompatibility
Using config file: /usr/src/phpSniffer/CodeSniffer.conf

Config value "installed_paths" added successfully
$ php phpcs.phar -i
The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend and PHPCompatibility
$ php phpcs.phar -p /var/www/vhosts/php56site.com/ --standard=PHPCompatibility

PHP Fatal error:  Uncaught Error: Class 'PHPCSUtils\Tokens\Collections' not found in /usr/src/phpSniffer/PHPCompatibility/PHPCompatibility/Sniffs/Miscellaneous/RemovedAlternativePHPTagsSniff.php:57
Stack trace:
#0 phar:///usr/src/phpSniffer/phpcs.phar/src/Ruleset.php(3): PHPCompatibility\Sniffs\Miscellaneous\RemovedAlternativePHPTagsSniff->register()
#1 phar:///usr/src/phpSniffer/phpcs.phar/src/Ruleset.php(3): PHP_CodeSniffer\Ruleset->populateTokenListeners()
#2 phar:///usr/src/phpSniffer/phpcs.phar/src/Runner.php(3): PHP_CodeSniffer\Ruleset->__construct(Object(PHP_CodeSniffer\Config))
#3 phar:///usr/src/phpSniffer/phpcs.phar/src/Runner.php(3): PHP_CodeSniffer\Runner->init()
#4 /usr/src/phpSniffer/phpcs.phar(6): PHP_CodeSniffer\Runner->runPHPCS()
#5 {main}
  thrown in /usr/src/phpSniffer/PHPCompatibility/PHPCompatibility/Sniffs/Miscellaneous/RemovedAlternativePHPTagsSniff.php on line 57

I'd expect the following behaviour

For this to be sufficient to run PHPCompatibility from a plain linux/php install. If not, then your readme.md needs updating because the non-composer install method doesn't work as described.

Instead this happened

Crash/fatal error due to not properly finding the first class in PHPsniffer that it tries to use.

Environment

No composer, plain debian (9/11/12), all of these result in a fatal error.
PHP versions tested: 7.0.33, 8.2.7

Tested Against develop branch?

No, just master branch.

For this to be sufficient to run PHPCompatibility from a plain linux/php install. If not, then your readme.md needs updating because the non-composer install method doesn't work as described.

@AphidGit The README describes the installation steps for use with the latest released version (master branch) and will work fine if you check out the last released tag.
The README will be updated when the next version is released to reflect the state of things for the next version.

If you want to use the develop version, it's up to you to keep yourself informed of changes.
Just so you know, as of the next release (10.0.0), installation without using Composer will no longer be supported (because of the type of issues you are reporting). Stand-alone installation will still be perfectly possible, but if you want to do that, you're on your own.

I managed to find how to do it; there's an undocumented dependency that is causing this error.

Solving it is as simple as cloning another repository;

cd /usr/src/phpSniffer/
git clone https://github.com/PHPCSStandards/PHPCSUtils
phpcs --config-set installed_paths /usr/src/phpSniffer/PHPCompatibility,/usr/src/phpSniffer/PHPCSUtils

@AphidGit Glad to hear you got things working. Does that mean we can close the issue ?

I'd update the documentation so other new users don't run into the same problem in the future, then close the issue.

The README will be updated when the next version is released to reflect the state of things for the next version.