phppharphpcs

phpcbf complains about missing CodeSniffer


The Problem

phpcbf complains about missing CodeSniffer but it appears to be missing from its own phar.

My setup

Ubuntu 14.04 using ondrej ppa for PHP 5.6

Here's what I've tried for installation and the output to verify installation

How I'm running phpcbf

php phpcbf.phar --standard=PSR2 ./MyDir/MyClass.php

PHP Warning: chdir(): No such file or directory (errno 2) in phar:///home/myuser/projects/myproject/src/phpcbf.phar/CodeSniffer.php on line 861

Update: Despite the warning, it seems to work fine.


Solution

  • PEAR is way out of date in 2017.

    You should be using composer nowadays instead:

    composer require squizlabs/php_codesniffer --dev
    

    Then run like:

    vendor/bin/phpcs ...
    

    To get more details about PEAR timeout, there is RFC about PEAR removal for PHP 8.