PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
To check a file against the PEAR coding standard, simply specify the file's location.
docker container run --rm -it -v "$(pwd)":/mnt mgilbert/phpcs phpcs myfile.php
Or, if you wish to check an entire directory instead of a file.
docker container run --rm -it -v "$(pwd)":/mnt mgilbert/phpcs phpcs .
Printing a List of Installed Coding Standards
docker container run --rm -it -v "$(pwd)":/mnt mgilbert/phpcs phpcs -i
Check for violations of the PSR2 coding standard
docker container run --rm -it -v "$(pwd)":/mnt mgilbert/phpcs phpcs --standard=PSR2 myfile.php
Check for violations of the Squiz coding standard
docker container run --rm -it -v "$(pwd)":/mnt mgilbert/phpcs phpcs --standard=Squiz myfile.php
docker container run --rm -it --entrypoint='bash' mgilbert/phpcs
- PHP_CodeSniffer
- GNU bash
- GNU patch
- PHP 7.2 (cli)
The documentation for PHP_CodeSniffer is available on the Github wiki.