/silverstripe-coding-standards

Coding standards tools for your SilverStripe project

Primary LanguageJavaScriptMIT LicenseMIT

SilverStripe Coding Standards

Set of definition and coding standards rules for your SilverStripe project

Install

Via Composer

composer require --dev jdolba/silverstripe-coding-standards ^0.1

Usage

Example of usage with composer scripts:

  • Add scripts to your composer.json file
    "scripts": {
        "silverstripe-standards": [
            "@php-lint",
            "@phpcs"
        ],
        "php-lint": "parallel-lint app/src app/tests",
        "phpcs": "phpcs app/src app/tests --standard=vendor/jdolba/silverstripe-coding-standards/definitions/php/phpcs-ss4.xml --extensions=php --encoding=utf-8",
        "phpcbf": "phpcbf app/src app/tests --standard=vendor/jdolba/silverstripe-coding-standards/definitions/php/phpcs-ss4.xml --extensions=php --encoding=utf-8",
        "phpcs-fix": "@phpcbf"
    },
  • then run:
composer silverstripe-standards
  • to fix your Standards violations you can run
composer phpcs-fix
# or
composer phpcbf

Custom rules

you can also customize rules by adding phpcs.xml file directly to you project root:

cp vendor/jdolba/silverstripe-coding-standards/skeletons/phpcs.xml phpcs.xml

don't forgot to change paths in composer scripts (--standard=phpcs.xml)

.editorconfig

you can use prepared .editorconfig file (see https://editorconfig.org/)

cp vendor/jdolba/silverstripe-coding-standards/skeletons/.editorconfig .editorconfig 

Credits

License

The MIT License (MIT). Please see License File for more information.