Brand Embassy Coding Standard
- The PHP_CodeSniffer ruleset to check that repositories are following the unified coding standard for Brand Embassy projects.
- The PHPStan default configuration file.
- PhpStorm code style and inspections (with Php Inspections (EA Extended) plugin) configuration files.
For full reference of enforcements, go through
src/BrandEmbassyCodingStandard/ruleset.xml where each sniff is briefly described.
@TODO list of important sniffs
For example to skip Function comment sniff:
/** * @phpcsSuppress BrandEmbassyCodingStandard.Commenting.FunctionComment */
- Some sniffs from SlevomatCodingStandards
You can install the Brand Embassy Coding Standard as a composer dependency to your project:
$ composer require --dev brandembassy/coding-standard
You can run PHP_CodeSniffer with this command:
$ ./vendor/bin/phpcs --standard=BrandEmbassyCodingStandard /path/to/some/file/to/sniff.php
You might also do automatic fixes using
$ ./vendor/bin/phpcbf --standard=BrandEmbassyCodingStandard /path/to/some/file/to/sniff.php
- includes phpstan-strict-rules extension
- includes phpstan-nette extension
- includes max level configuration by default
To use default configuration include default-phpstan.neon in your project's PHPStan config:
includes: - vendor/brandembassy/coding-standard/integration-phpstan.neon
This project contains inspections and code style configurations for PhpStorm.
Importing these configurations reduces number of errors in
phpcs check before committing.
This library follows semantic versioning, and additions to the code ruleset are only performed in major releases.
@TODO: inspiration - https://github.com/doctrine/coding-standard/tree/master/tests
If you are contributing to the Brand Embassy Coding Standard and want to test your contribution, you just need to execute PHPCS with the tests folder and ensure it matches the expected report:
$ ./vendor/bin/phpcs tests/input --report=summary --report-file=phpcs.log; diff tests/expected_report.txt phpcs.log