PHPackages                             devbeta/psr12-strict-rules - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. devbeta/psr12-strict-rules

ActivePhpcodesniffer-standard

devbeta/psr12-strict-rules
==========================

PSR-12 strict coding standard

1.0.3(4y ago)1202↑1900%1BSD-3-ClausePHP ^8.0

Since Oct 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/devbeta/psr12-strict-rules)[ Packagist](https://packagist.org/packages/devbeta/psr12-strict-rules)[ RSS](/packages/devbeta-psr12-strict-rules/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (5)Used By (0)

PSR-12 Strict Coding Standard
=============================

[](#psr-12-strict-coding-standard)

This specification extends and expands [PSR-12](https://www.php-fig.org/psr/psr-12/), the extended coding style guide and requires adherence to [PSR-1](https://www.php-fig.org/psr/psr-1), the basic coding standard.

Contributors have different coding styles and so do the maintainers. During code reviews there are regularly discussions about spaces and alignments, where and when was said that a function needs to be imported. And that's where this coding standard comes in: To have internal consistency in a component and between components.

Installation
------------

[](#installation)

Install the module via composer by running:

```
composer require --dev devbeta/psr12-strict-rules
```

Usage
-----

[](#usage)

Create file `phpcs.xml` on base path of your repository with this content:

```

    PSR-12 strict coding standard

    config
    src
    tests

```

You can add or exclude some locations in that file. For a reference please see: [Annotated Ruleset](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset)

Coding Style Guide
------------------

[](#coding-style-guide)

### Basic Coding Standard

[](#basic-coding-standard)

- Code MUST follow all rules outlined in PSR-12.

### Arrays

[](#arrays)

- All values in multiline arrays must be indented with 4 spaces.
- The short array syntax MUST be used to define arrays.

### Classes

[](#classes)

- There MUST NOT be duplicate class names.
- Checks the declaration of the class and its inheritance is correct.
- The file name MUST match the case of the terminating class name.
- For self-reference a class lower-case `self::` MUST be used without spaces around the scope resolution operator.

### Code Analysis

[](#code-analysis)

- The final keyword on methods MUST be omitted in final classes.
- Detects unnecessary overridden methods that simply call their parent.

### Control Structures

[](#control-structures)

- Verifies that control statements conform to their coding standards.
- Ensure multi-line `if` conditions are defined correctly.

### Formatting

[](#formatting)

- There MUST be one whitespace after a type casting operator.
- There MUST be one whitespace after unary not.
- If an assignment goes over two lines, ensure the equal sign is indented.

### Functions

[](#functions)

- Ensure single and multi-line function declarations are defined correctly.

### Metrics

[](#metrics)

- Checks the cyclomatic complexity (McCabe) for functions.
- Checks the nesting level for methods.

### Naming Conventions

[](#naming-conventions)

- Checks that abstract classes are prefixed by Abstract.
- Ensures method and functions are named correctly.
- Checks that interfaces are suffixed by Interface.
- Checks that traits are suffixed by Trait.

### Operators

[](#operators)

- The `&&` and `||` operators SHOULD be used instead of `and` and `or`.

### PHP

[](#php)

- The backtick operator MUST NOT be used.
- Deprecated PHP functions MUST be avoided.
- The PHP `goto` language construct SHOULD NOT be used.
- Alias functions SHOULD NOT be used.
- Throws an error or warning when any code prefixed with an asperand is encountered.
- Checks that the `strict_types` has been declared.
- The constant `PHP_SAPI` SHOULD be used instead of the `php_sapi_name()` function.
- The `global` keyword MUST NOT be used.
- PHP function calls MUST be in lowercase.
- Non executable code MUST be removed.

### Scope

[](#scope)

- The pseudo-variable `$this` MUST NOT be called inside a static method or function.

### Strings

[](#strings)

- Checks that two strings are not concatenated together; suggests using one string instead.
- Makes sure there are no spaces around the concatenation operator.

### WhiteSpace

[](#whitespace)

- Check &amp; fix whitespace on the inside of arbitrary parentheses.
- Verifies spacing between the spread operator and the variable/function call it applies to.
- Checks that object operators are indented correctly.
- Checks that the closing braces of scopes are aligned correctly.
- Checks the separation between functions and methods.
- There MUST be a single space after language constructs.
- There MUST NOT be any white space around the object operator UNLESS multilines are used.
- Verifies that class members are spaced correctly.
- Ensure there is no whitespace before/after an object operator.
- Verifies that operators have valid spacing surrounding them.
- There MUST NOT be a space before a semicolon. Redundant semicolons SHOULD be avoided.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1652d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/722f7b07590207592108c642fa081c1deee3b3f306c989bb350a93174d58bdd0?d=identicon)[devbeta](/maintainers/devbeta)

---

Top Contributors

[![devbeta](https://avatars.githubusercontent.com/u/3442663?v=4)](https://github.com/devbeta "devbeta (6 commits)")

---

Tags

codesnifferpsr-12

### Embed Badge

![Health badge](/badges/devbeta-psr12-strict-rules/health.svg)

```
[![Health](https://phpackages.com/badges/devbeta-psr12-strict-rules/health.svg)](https://phpackages.com/packages/devbeta-psr12-strict-rules)
```

###  Alternatives

[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k123.5M1.8k](/packages/slevomat-coding-standard)[drupal/coder

Coder is a library to review Drupal code.

3043.6M460](/packages/drupal-coder)[mayflower/mo4-coding-standard

PHP CodeSniffer ruleset implementing the MO4 coding standards extending the Symfony coding standards.

17508.3k5](/packages/mayflower-mo4-coding-standard)[chromatic/usher

A collection of Robo commands for use on Chromatic projects.

13534.3k1](/packages/chromatic-usher)[youwe/testing-suite

Contains Youwe's default testing packages for php.

13176.9k8](/packages/youwe-testing-suite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
