PHPCS is a tool that helps detect violations of pre-defined coding standards. It also includes an additional tool that can automatically correct those violations
PHP_CodeSniffer requires PHP version 5.4.0 or greater, although individual sniffs may have additional requirements such as external applications and scripts.
If you’re using PHP_CodeSniffer as part of a team, or you’re running it on a Continuous Integration(CI) server, you may want to configure your project’s settings using a configuration file.
Please refer the URL = https://github.com/squizlabs/PHP_CodeSniffer
// Discover violation of coding standards
phpcs –standard=Drupal –extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /path/to/drupal/example_module
phpcs –standard=Drupal /to/drupal/example_module
// Automatically fix coding standards
phpcbf –standard=Drupal /to/drupal/example_module
phpcs –standard=DrupalPractice –extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /path/to/drupal/example_module