Search code examples
macoscomposer-phppearphpcodesniffer

Can't remove old PHP_CodeSniffer install


My employer has asked me to move from a PEAR phpcs install to a global Composer phpcs install. In trying to make that change, I've discovered an existing phpcs of an old version.

macpro@~ $: which phpcs
/usr/local/bin/phpcs
macpro@~ $: /usr/local/bin/phpcs --version
PHP_CodeSniffer version 2.3.4 (stable) by Squiz (http://www.squiz.net)

This version doesn't match with PEAR or Composer versions I've installed.

macpro@~/bin/phpcs $: pear list
Installed packages, channel pear.php.net:
=========================================
Package          Version State
Archive_Tar      1.4.0   stable
Console_Getopt   1.4.1   stable
PEAR             1.10.1  stable
PHP_CodeSniffer  2.6.0   stable
Structures_Graph 1.1.1   stable
XML_Util         1.3.0   stable
macpro@~/.composer $: composer info
squizlabs/php_codesniffer 2.6.0 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.

I cannot update or uninstall this old version using PEAR. I remove and reinstall PHP_CodeSniffer using PEAR and nothing changes.

I thought maybe I had installed the old phpcs version with MacPorts. Installed MacPorts to check.

macpro@~ $: port installed
No ports are installed.

So my question is, how can I remove this old phpcs installation (without breaking anything, and in such a way that I can, ultimately uninstall every instance of phpcs except a globally available composer package)?


Solution

  • Is that phpcs executable a script, or a phar file? If it's a phar file then it definitely wasn't placed there by a PEAR install.

    $ file /usr/local/bin/phpcs

    You should either get: /usr/local/bin/phpcs: PHP script, ASCII text executable or /usr/local/bin/phpcs: data

    If you get "data", then it's most likely a phar in which case you can simply delete it.

    If it was placed there via PEAR, or if you know there's a PEAR install of phpcs laying about, you can do a check of sorts to see where the PEAR installed script is by doing:

    $ pear list PHP_CodeSniffer | grep "phpcs$"