perceptiontech/php-coding-standard

PHP coding standard to use with PHPCodeSniffer

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:phpcodesniffer-standard

0.0.2 2019-03-08 09:12 UTC

This package is auto-updated.

Last update: 2024-05-08 22:20:45 UTC


README

This standard follows the (Symfony standards)[https://symfony.com/doc/current/contributing/code/standards.html] with with the following exceptions:

  • It does not require the license on top of every file.
  • It allows to have multiline function arguments.

Installation steps

  1. Install PHP code sniffer: https://github.com/squizlabs/PHP_CodeSniffer#installation

  2. Require package globally using composer:

    $ composer global require "perceptiontech/php-coding-standard"
  3. Add the coding standard to the PHP_CodeSniffer install path (under MacOS and Linux):

    $ phpcs --config-set installed_paths ~/.composer/vendor/perceptiontech/php-coding-standard

    Be aware that, if you already have installed paths, they will be lost. If so, you will have to execute:

    $ phpcs --config-set installed_paths ~/.composer/vendor/perceptiontech/php-coding-standard,/path/to/already/insatlled/standard/
  4. Check the installed standards for "Perception":

    $ phpcs -i

PHPStorm configuration

Code_Sniffer configuration

  1. Go to quality tools, unfold the Code Sniffer option and toggle the configuration by clicking on ...:

    PHPStorm CodeSniffer configuration

  2. Set the path to your local PHPCode_Sniffer binary and validate it:

    PHPStorm CodeSniffer binary

Ruleset configuration

  1. Go to Editor > Inspections > PHP > Quality tools > PHP Code Sniffer validation

    PHPStorm CodeSniffer insepctions

  2. Enable the configuration, refresh the "Coding standard" and select "Perception". Configuration should be as it follows:

    PHPStorm CodeSniffer insepctions

    (NOTE: set the severity as "warning". Otherwise, it is difficult to spot the errors within the editor)

  3. After this configuration, PHPStorm should inform you whenever a piece of code is not correct according to the rules:

    PHPStorm CodeSniffer insepctions