PHPackages                             xactsystems/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. [Testing &amp; Quality](/categories/testing)
4. /
5. xactsystems/phpstan-extensions

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

xactsystems/phpstan-extensions
==============================

A collection of PHPStan extensions found useful in our projects.

v1.0.2(2y ago)0121MITPHPPHP ^7.4 || ^8.0

Since Aug 31Pushed 2y ago1 watchersCompare

[ Source](https://github.com/XactSystems/phpstan-extensions)[ Packagist](https://packagist.org/packages/xactsystems/phpstan-extensions)[ RSS](/packages/xactsystems-phpstan-extensions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (1)

A collection of PHPStan extensions
==================================

[](#a-collection-of-phpstan-extensions)

This repo contains some useful PHPStan extension for detecting errors in your code. The currently list of rules is:

`UnusedClassRule`
-----------------

[](#unusedclassrule)

`UnusedTraitRule`
-----------------

[](#unusedtraitrule)

Install
-------

[](#install)

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

Usage
-----

[](#usage)

With [PHPStan extension installer](https://github.com/phpstan/extension-installer), everything is ready to run.

Otherwise manually enable the extension:

```
# phpstan.neon
include:
    'vendor/xactsystems/phpstan-extensions/config/extension.neon'

```

Rules
-----

[](#rules)

---

### `UnusedClassRule`

[](#unusedclassrule-1)

This rule scans for class declarations and use statements. If a class is declared but not used within the scanned source files, an error is generated.

### Disabling the rule

[](#disabling-the-rule)

You can disable scanning classes as follows:

```
# phpstan.neon
parameters:
    unused_classes:
        classes: false
```

#### Excluding files

[](#excluding-files)

You can exclude directories and individual files from being scanned by this rule:

```
# phpstan.neon
parameters:
    unused_classes:
        excludePaths:
            - 'src/Controller'
            - 'src/MyUnusedClass.php'
```

### Excluding Services

[](#excluding-services)

By default, some known service and framework classes are excluded. There are a number of base classes from Symfony, Doctrine and PHPUnit that checked and, if matched, the class being analysed is ignored.

To disable this, set the *excludeFrameworks* property to false:

```
# phpstan.neon
parameters:
    unused_classes:
        excludeFrameworks: false
```

This list will change as new frameworks and classes are added. Please look at the source code in src/Frameworks for a list of base classes that are excluded.

If you want add a custom list of base classes to ignore, use the *baseClassExcludes* property:

```
# phpstan.neon
parameters:
    unused_classes:
        baseClassExcludes:
            - 'App\Service\MyAbstractService'
            - 'App\DI\MyDIClass'
```

Entries in *baseClassExcludes* are excluded regardless of the *excludeFrameworks* property value.

---

### `UnusedTraitRule`

[](#unusedtraitrule-1)

This rule scans for trait declarations and use statements. If a trait is declared but not used within the scanned source files, an error is generated.

### Disabling the rule

[](#disabling-the-rule-1)

You can disable scanning traits as follows:

```
# phpstan.neon
parameters:
    unused_classes:
        traits: false
```

#### Excluding files

[](#excluding-files-1)

You can exclude directories and individual files from being scanned by this rule using the excludePaths parameter as shown above.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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 ~3 days

Total

2

Last Release

978d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dfec2e953df9e01a16d4cebd810aebc86832067d8a55df8c546c3917a5e89465?d=identicon)[ianef](/maintainers/ianef)

---

Top Contributors

[![ianef](https://avatars.githubusercontent.com/u/5128087?v=4)](https://github.com/ianef "ianef (8 commits)")

---

Tags

extensionsphpphpstanunused-classesPHPStanstatic analysis

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[szepeviktor/phpstan-wordpress

WordPress extensions for PHPStan

3257.8M887](/packages/szepeviktor-phpstan-wordpress)[ekino/phpstan-banned-code

Detected banned code using PHPStan

2925.6M92](/packages/ekino-phpstan-banned-code)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

3462.2M51](/packages/shipmonk-dead-code-detector)[staabm/phpstan-dba

2912.3M2](/packages/staabm-phpstan-dba)[staabm/phpstan-todo-by

1991.8M54](/packages/staabm-phpstan-todo-by)

PHPackages © 2026

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