roslov / psr12ext

PSR-12 Extended Coding Standard
MIT License
3 stars 1 forks source link

PSR-12 Extended Coding Standard

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

This repository extends the PSR-12 coding style.

In addition to PSR-12 this coding style also contains some rules from the Slevomat Coding Standard and PHP_CodeSniffer.

Using This Code Style

After CodeSniffer is installed, you can launch it with a custom code style using the following syntax:

composer require --dev roslov/psr12ext
./vendor/bin/phpcs --extensions=php --standard=PSR12Ext /app

If you are planning to integrate the code quality check with your IDE or CI, create the file ruleset.xml in the project’s root folder.

This file can include the list of rules you want to disable, as well as your custom settings. For example:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="project-code-styling">
    <description>Local Project Coding Standard</description>

    <!-- Excludes vendor and temporary folders -->
    <exclude-pattern>vendor/*</exclude-pattern>
    <exclude-pattern>var/*</exclude-pattern>

    <!-- Base standards (if not detected) -->
    <config name="installed_paths" value="vendor/roslov/psr12ext" />

    <!-- Base rules -->
    <rule ref="PSR12Ext">
        <!-- Ignores line endings -->
        <exclude name="Generic.Files.LineEndings" />
        <!-- Disables strict type requirement -->
        <exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" />
        <!-- Ignores missing parentheses in class instantiation -->
        <exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses" />
    </rule>

    <!-- Rules for tests -->
    <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
        <exclude-pattern>tests/*</exclude-pattern>
    </rule>
    <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
        <exclude-pattern>tests/*</exclude-pattern>
    </rule>
</ruleset>

The List Of Rules Used In This Coding Standard

All used rules with their options are described in PSR12Ext/ruleset.xml.

Below you can find only names of the rules:

Versioning

PSR-12 Extended Coding Standard uses a MAJOR.MINOR.PATCH version number format.

The MAJOR version is incremented when:

The MINOR version is incremented when:

The PATCH version is incremented when: