valicm
5/3/2018 - 8:42 PM

Coding standards Drupal

Download composer local - https://getcomposer.org/download/

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

mv composer.phar /usr/local/bin/composer

Install composer (global) (see per each platform specifics - https://getcomposer.org/doc/00-intro.md

mv composer.phar /usr/local/bin/composer

Install phpcs

composer global require "squizlabs/php_codesniffer=*"

Install Coder

composer global require drupal/coder

PHPStorm code style

Settings -> Code style -> PHP, CSS, Javascript, HTML, SCSS, SASS, YAML -> set Drupal style (if does not exist specific for drupal, use from language where Drupal style is assigned)

PhpStorm code inspection

Check this checkbox: File -> Settings -> Editor -> Inspections -> PHP -> PHP Code Sniffer validation

Coding Standard -> choose custom

Select ruleset.xml -> from your local composer folder composer/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml

(on linux is entire path: /home/valic/.config/composer/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml