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
Requires
- escapestudios/symfony2-coding-standard: ^3.5.2
- squizlabs/php_codesniffer: ^3.3.1
This package is auto-updated.
Last update: 2025-01-08 23:41:14 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
-
Install PHP code sniffer: https://github.com/squizlabs/PHP_CodeSniffer#installation
-
Require package globally using composer:
$ composer global require "perceptiontech/php-coding-standard"
-
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/
-
Check the installed standards for "Perception":
$ phpcs -i
PHPStorm configuration
Code_Sniffer configuration
-
Go to quality tools, unfold the Code Sniffer option and toggle the configuration by clicking on
...
: -
Set the path to your local PHPCode_Sniffer binary and validate it:
Ruleset configuration
-
Go to Editor > Inspections > PHP > Quality tools > PHP Code Sniffer validation
-
Enable the configuration, refresh the "Coding standard" and select "Perception". Configuration should be as it follows:
(NOTE: set the severity as "warning". Otherwise, it is difficult to spot the errors within the editor)
-
After this configuration, PHPStorm should inform you whenever a piece of code is not correct according to the rules: