egeniq/php-coding-standard

The Egeniq Coding Standard is a set of PHPCS rules that we use at Egeniq, it's based on the Doctrine project.

Installs: 12 474

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 9

Forks: 0

Open Issues: 0

Type:phpcodesniffer-standard

1.2.0 2022-09-14 09:24 UTC

This package is auto-updated.

Last update: 2024-11-14 13:55:53 UTC


README

The Egeniq Coding Standard is a set of PHP_CodeSniffer rules that we use at Egeniq. The standard is heavily based on Doctrine Coding Standard.

Installation

You can install the Egeniq coding standard as a composer dependency to your particular project. Just run the following command to add it to your project:

php composer require --dev egeniq/php-coding-standard

Then you can use it like:

vendor/bin/phpcs --standard=Egeniq /path/to/some/file/to/sniff.php

You might also do automatic fixes using phpcbf:

vendor/bin/phpcbf --standard=Egeniq /path/to/some/file/to/sniff.php

Project-level ruleset

To enable the Egeniq coding standard for your project, create a phpcs.xml.dist file with the following content:

<?xml version="1.0"?>
<ruleset>
    <arg name="basepath" value="."/>
    <arg name="extensions" value="php"/>
    <arg name="parallel" value="80"/>
    <arg name="cache" value=".phpcs-cache"/>
    <arg name="colors"/>

    <!-- Ignore warnings, show progress of the run and show sniff names -->
    <arg value="nps"/>

    <!-- Directories to be checked -->
    <file>app</file>
    <file>tests</file>

    <!-- Include full Egeniq coding standard -->
    <rule ref="Egeniq">
        <!-- sniffs to exclude -->
        <!-- by default strict types are required, but if you wish to disable this, exclude the following sniff:
        <exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>
        -->
    </rule>
</ruleset>

This will enable verbatim the Egeniq coding standard with all rules included with their defaults. From now on you can just run vendor/bin/phpcs and vendor/bin/phpcbf without any arguments 🙌.