kcs/phpstan-strict-rules

A set of additional rules for PHPStan based on best practices followed at TheCodingMachine

Maintainers

πŸ‘ alekitto

Package info

github.com/alekitto/phpstan-strict-rules

Type:phpstan-extension

pkg:composer/kcs/phpstan-strict-rules

Statistics

Installs: 38 623

Dependents: 1

Suggesters: 0

Stars: 3

v2.1.0 2025-09-28 09:26 UTC

Requires

Requires (Dev)

Suggests

None

Conflicts

None

Replaces

None

MIT b50b5b0674e2ce1ce9e1275683b7b758e2c511aa

  • David NΓ©grier <d.negrier.woop@thecodingmachine.com>
  • Alessandro Chitolina <alekitto.woop@gmail.com>

README

πŸ‘ Latest Stable Version
πŸ‘ Total Downloads
πŸ‘ Latest Unstable Version
πŸ‘ License
πŸ‘ Scrutinizer Code Quality
πŸ‘ Build Status
πŸ‘ Coverage Status

This is a fork of the popular thecodingmachine/phpstan-strict-rules

To push forward the development of this package and the adoption of phpstan v2, this package has been forked, as the original repository seems semi-abandoned. Versioning starts from 2.0 and retains all the features of the original package. Namespace has not been changed.

Once the original project restarts, it is possible that this package would be abandoned. In case the original package is left abandoned for a longer time, this will be a hard fork, with different namespaces and so on...

TheCodingMachine's additional rules for PHPStan

This package contains a set of rules to be added to the wonderful PHPStan static analyzer.

Those rules come from TheCodingMachine best practices. They are more "strict" than the default PHPStan rules and some may be controversial. We use those at TheCodingMachine, have found them to help us in our daily work, and ask anyone working with us to follow them.

Rules list

Exception related rules

Superglobal related rules

Condition related rules

Work-in-progress

// Never use public properties
// Never use globals

Installation

We assume that PHPStan is already installed in your project.

To use this extension, require it in Composer:

composer require --dev thecodingmachine/phpstan-strict-rules

If you also install phpstan/extension-installer then you're all set!