PHPackages                             slam/phpstan-extensions - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. slam/phpstan-extensions

ActivePhpstan-extension[Utility &amp; Helpers](/categories/utility)

slam/phpstan-extensions
=======================

Slam extension of phpstan

v6.8.0(6mo ago)702.5M—5.4%13[2 issues](https://github.com/Slamdunk/phpstan-extensions/issues)[3 PRs](https://github.com/Slamdunk/phpstan-extensions/pulls)20MITPHPPHP ~8.4.0 || ~8.5.0CI passing

Since Jan 8Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/Slamdunk/phpstan-extensions)[ Packagist](https://packagist.org/packages/slam/phpstan-extensions)[ Fund](https://paypal.me/filippotessarotto)[ GitHub Sponsors](https://github.com/Slamdunk)[ RSS](/packages/slam-phpstan-extensions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (38)Used By (20)

Slam PHPStan extensions
=======================

[](#slam-phpstan-extensions)

[![Latest Stable Version](https://camo.githubusercontent.com/285a22ac32ae06bf5a7cddfd41e82ba52d0873b1c5e6f8b8ef0b08f8cbc89340/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c616d2f7068707374616e2d657874656e73696f6e732e737667)](https://packagist.org/packages/slam/phpstan-extensions)[![Downloads](https://camo.githubusercontent.com/a19b85cfa5e1ddd3e0f58be02660b7baccb916a3d69873273ef29d6ca771cd74/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c616d2f7068707374616e2d657874656e73696f6e732e737667)](https://packagist.org/packages/slam/phpstan-extensions)[![Integrate](https://github.com/Slamdunk/phpstan-extensions/workflows/CI/badge.svg)](https://github.com/Slamdunk/phpstan-extensions/actions)[![Code Coverage](https://camo.githubusercontent.com/45cb7ff16754a6870e4310e4a0f2f95ec4e2b1c3a29c491ec89ef99130c8ff1f/68747470733a2f2f636f6465636f762e696f2f67682f536c616d64756e6b2f7068707374616e2d657874656e73696f6e732f636f7665726167652e737667)](https://codecov.io/gh/Slamdunk/phpstan-extensions)

Extensions for [PHPStan](https://phpstan.org/)

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

[](#installation)

To use this extension, require it in [Composer](https://getcomposer.org/):

```
composer require --dev slam/phpstan-extensions
```

Usage
-----

[](#usage)

When you are using [`phpstan/extension-installer`](https://github.com/phpstan/extension-installer), `conf/slam-rules.neon` will be automatically included.

Otherwise you need to include `conf/slam-rules.neon` in your `phpstan.neon`:

```
includes:
    - vendor/slam/phpstan-extensions/conf/slam-rules.neon
```

Rules
-----

[](#rules)

1. `SlamPhpStan\UnusedVariableRule`: check for variable inside functions never used after initial assignment
2. `SlamPhpStan\MissingClosureParameterTypehintRule`: requires parameter typehints for closures; WARNING: no PhpDoc allowed, see [`phpstan/phpstan-strict-rules#87`](https://github.com/phpstan/phpstan-strict-rules/issues/87)
3. `SlamPhpStan\StringToClassRule`: requires strings that refer to classes to be expressed with `::class` notation
4. `SlamPhpStan\GotoRule`: no goto allowed
5. `SlamPhpStan\ClassNotationRule`:
    1. Interfaces must end with "Interface"
    2. Traits must end with "Trait"
    3. Abstract classes must start with "Abstract"
    4. Exceptions must end with "Exception"
6. `SlamPhpStan\PhpUnitFqcnAnnotationRule`: classes found in following PHPUnit annotations must exist:
    1. `@expectedException`
    2. `@covers`
    3. `@coversDefaultClass`
    4. `@uses`
7. `SlamPhpStan\AccessGlobalVariableWithinContextRule`: inhibit the access to globals within classes that extend or implement a certain class/interface
8. `SlamPhpStan\AccessStaticPropertyWithinModelContextRule`: inhibit the access to static attributes of a class within classes that extend or implement a certain class/interface, useful to prohibit usage of singletons in models

Not-NOW config
--------------

[](#not-now-config)

A `not-now-rules.neon` config is present for forbidding raw date system calls:

```
includes:
    - vendor/slam/phpstan-extensions/conf/not-now-rules.neon
```

These rules forbid:

1. `new DateTimeImmutable()`
2. `new DateTime('yesterday')`
3. `date('Y-m-d')`
4. `time()`, `microtime()`
5. `strtotime('noon')`

You should instead rely on a clock abstraction like [`lcobucci/clock`](https://github.com/lcobucci/clock).

WARNING: the rules are not perfect, a user can tricks them easily; they are meant only to help the transition to a proper clock abstraction.

Symfony-specific config
-----------------------

[](#symfony-specific-config)

A `symfony-rules.neon` config is present for Symfony projects:

```
includes:
    - vendor/slam/phpstan-extensions/conf/symfony-rules.neon
```

With the following configurations:

1. `SlamPhpStan\SymfonyFilesystemRule`: forbid calls to raw filesystem functions well wrapped by [`symfony/filesystem`](https://github.com/symfony/filesystem) component
2. `SlamPhpStan\SymfonyProcessRule`: forbid calls to raw system functions well wrapped by [`symfony/process`](https://github.com/symfony/process) component

Yii-specific config
-------------------

[](#yii-specific-config)

A `yii-rules.neon` config is present for Yii projects:

```
includes:
    - vendor/slam/phpstan-extensions/conf/yii-rules.neon
```

With the following configurations:

1. `SlamPhpStan\AccessGlobalVariableWithinContextRule` to deny the usage of `$_GET`, `$_POST` and other global variables in models implementing `yii\db\ActiveRecordInterface`: accessing to singletons in models is considered an anti-pattern
2. `SlamPhpStan\AccessStaticPropertyWithinModelContextRule` to deny the usage of `yii\BaseYii` static variables like `$app` in models implementing `yii\db\ActiveRecordInterface`: accessing to singletons in models is considered an anti-pattern

###  Health Score

69

—

FairBetter than 100% of packages

Maintenance79

Regular maintenance activity

Popularity55

Moderate usage in the ecosystem

Community36

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 66.7% 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 ~89 days

Recently: every ~114 days

Total

33

Last Release

199d ago

Major Versions

v1.2.1 → v2.0.02018-06-26

v2.0.1 → v3.0.02019-01-24

v3.6.1 → v4.0.02019-12-08

v4.0.0 → v5.0.02020-02-18

v5.1.0 → v6.0.02021-11-09

PHP version history (7 changes)v1.0.0PHP ^7.1

v5.0.1PHP ^7.1|^8.0

v5.1.0PHP ^7.4 || ^8.0

v6.0.0PHP &gt;=8.0

v6.1.0PHP ~8.2.0 || ~8.3.0

v6.5.0PHP ~8.3.0 || ~8.4.0

v6.7.0PHP ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50348?v=4)[Sahn Lam](/maintainers/Slam)[@slam](https://github.com/slam)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (174 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (76 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (2 commits)")[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (1 commits)")[![mfn](https://avatars.githubusercontent.com/u/87493?v=4)](https://github.com/mfn "mfn (1 commits)")[![voku](https://avatars.githubusercontent.com/u/264695?v=4)](https://github.com/voku "voku (1 commits)")[![marcingy](https://avatars.githubusercontent.com/u/192095?v=4)](https://github.com/marcingy "marcingy (1 commits)")[![temp](https://avatars.githubusercontent.com/u/216128?v=4)](https://github.com/temp "temp (1 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (1 commits)")[![nclundsten](https://avatars.githubusercontent.com/u/239653?v=4)](https://github.com/nclundsten "nclundsten (1 commits)")

---

Tags

phpphpstanstatic-analysisyii2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/slam-phpstan-extensions/health.svg)

```
[![Health](https://phpackages.com/badges/slam-phpstan-extensions/health.svg)](https://phpackages.com/packages/slam-phpstan-extensions)
```

###  Alternatives

[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87578.8k35](/packages/ticketswap-phpstan-error-formatter)[ramsey/devtools

A Composer plugin to aid PHP library and application development.

7134.7k26](/packages/ramsey-devtools)[johnbillion/wp-compat

PHPStan extension to help verify that your PHP code is compatible with a given version of WordPress

24115.0k10](/packages/johnbillion-wp-compat)

PHPackages © 2026

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