はじめに
php5からphp7に移行するため、PHOCoompatilibilityを使って古い関数などをチェックしようとしたところ、インストールしてないと怒られたので対処法を記録。
ERROR: the "PHPCompatibility" coding standard is not installed.
手順
1.phpcsがすでにインストールされているマシンにPHPCompatibilityをインストール
composer require --dev phpcompatibility/php-compatibility
Using version ^9.3 for phpcompatibility/php-compatibility
./composer.json has been updated
Running composer update phpcompatibility/php-compatibility
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking phpcompatibility/php-compatibility (9.3.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing phpcompatibility/php-compatibility (9.3.5): Extracting archive
1 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
2.動作確認 => インストールされてないよエラー
vendor/bin/phpcs --standard=PHPCompatibility
ERROR: the "PHPCompatibility" coding standard is not installed. The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1 and PSR12
3.PHPCompatibilityをオプションとして認識できるようにpathを設定
vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility
Using config file: /Users/honoka.arai/WORKSPACE/docker-boilerplate/data-host/batch/vendor/squizlabs/php_codesniffer/CodeSniffer.conf
Config value "installed_paths" added successfully
4.動作確認2 => filenameないよエラーなので、動いてるっぽい🥳
vendor/bin/phpcs --standard=PHPCompatibility
ERROR: You must supply at least one file or directory to process.
Run "phpcs --help" for usage information
最後に
意外と簡単に解決できてよかったです...
参考になれば幸いです🍎