PHP Code Sniffer custom rules pack
Installation instructions:
composer install
chmod +x phpcsx phpmd.phar
phpcsx
phpmd.phar
PHP Code Sniffer is a library, which can validate coding style standard and best practices to be in used.
You can check simple video to find out basics about PHPCS: https://www.youtube.com/watch?v=tKih3UZuwXw
PHP Mess Detector is another cool code analyzer tool. It can analyze possible bugs, suboptimal code, overcomplicated expressions, ununsed code, etc.
Inside PHP Storm you can configure to auto-run it directly inside your editor (default settings, when you enable an Inspection).
Or you can run a specific inspection from a menu: Code > Inspect Code. And then see all errors across some file or even folder.
By default PHPCS has a command line interface to run the same checks. For example, you can run:
./phpcsx --standard=JustcodedWordpress /var/www/wordpress/wp-content/themes/my-theme/
PHPStorm has it’s own built-in WordPress and PSR-2 code styles presets, however they follow only must rules and it some cases are not accurate.
We updated code styles to work with current WordPress repository rulesets and modern framework code styles.
You can find code styles inside phpstorm
directory in this repository.
To import a code style:
We belive that all code should be well documented and this means that all properties and methods should have a proper descriptions.
However some methods are self-explanatory like getters or setters. You can configure you PHPStorm to autocomplete short method name to help you minimize you text typing for self-explanatory methods.
To configure that:
#set( $name = ${NAME} )
/**
* $name.substring(0,1).toUpperCase()$name.substring(1).replaceAll("([A-Z])", " $1")
*
${PARAM_DOC}
#if (${TYPE_HINT} != "void") * @return ${TYPE_HINT}
#end
${THROWS_DOC}
*/