sebastiaanluca/php-codesniffer-ruleset

An opinionated custom coding standard.

0.4.3 2019-08-21 13:35 UTC

This package is auto-updated.

Last update: 2020-07-10 18:12:22 UTC


README

Latest stable release Software license Total downloads Total stars

Read my blog View my other packages and projects Follow @sebastiaanluca on Twitter

Table of contents

Requirements

How to install

composer require sebastiaanluca/php-codesniffer-ruleset --dev

How to use

Enabling the rules

Add it to your project phpcs.xml or phpcs.xml.dist ruleset:

<?xml version="1.0"?>
<ruleset>
    <arg name="basepath" value="."/>

    <file>./src</file>
    <file>./tests</file>

    <rule ref="./vendor/sebastiaanluca/php-codesniffer-ruleset/ruleset.xml"/>
</ruleset>

Sniffing code

The following commands can be added to the scripts section of your composer.json file to check and fix invalid code. Some optional checks are also included to illustrate how they might work together to check all your code.

{
    "scripts": {
        "composer-validate": "@composer validate --no-check-all --strict",
        "codesniffer-check": "vendor/bin/phpcs --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1",
        "codesniffer-fix": "vendor/bin/phpcbf --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 || exit 0",
        "test": "vendor/bin/phpunit",
        "check": [
            "@composer-validate",
            "@codesniffer-check",
            "@test"
        ]
    }
}

Sniffing code in PHPStorm

See PHP Code Sniffer in PhpStorm on how to set up CodeSniffer in PHPStorm.

License

This package operates under the MIT License (MIT). Please see LICENSE for more information.

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email hello@sebastiaanluca.com instead of using the issue tracker.

Credits

About

My name is Sebastiaan and I'm a freelance Laravel developer specializing in building custom Laravel applications. Check out my portfolio for more information, my blog for the latest tips and tricks, and my other packages to kick-start your next project.

Have a project that could use some guidance? Send me an e-mail at hello@sebastiaanluca.com!