PHPackages                             dave-liddament/phpstan-php-language-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. dave-liddament/phpstan-php-language-extensions

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

dave-liddament/phpstan-php-language-extensions
==============================================

PHPStan rules to implement the language extensions provided by the php-language-extensions

0.10.0(5mo ago)44385.8k↑36.5%4[1 PRs](https://github.com/DaveLiddament/phpstan-php-language-extensions/pulls)3MITPHPPHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Apr 22Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/DaveLiddament/phpstan-php-language-extensions)[ Packagist](https://packagist.org/packages/dave-liddament/phpstan-php-language-extensions)[ RSS](/packages/dave-liddament-phpstan-php-language-extensions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (19)Used By (3)

PHPStan PHP Language Extensions (currently in BETA)
===================================================

[](#phpstan-php-language-extensions-currently-in-beta)

[![PHP versions: 8.0 to 8.3](https://camo.githubusercontent.com/b0633bf4e3111246a7529f089f16fdbdaf313aa1df0b40005d4697ba0a702320/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e30253743382e31253743382e253743382e332d626c75652e737667)](https://packagist.org/packages/dave-liddament/phpstan-php-language-extensions)[![Latest Stable Version](https://camo.githubusercontent.com/e8569208a39b1eb7bc0366f5356669cee49a5f3c792e97cc2280aafad13fe90e/68747470733a2f2f706f7365722e707567782e6f72672f646176652d6c696464616d656e742f7068707374616e2d7068702d6c616e67756167652d657874656e73696f6e732f762f737461626c65)](https://packagist.org/packages/dave-liddament/phpstan-php-language-extensions)[![License](https://camo.githubusercontent.com/89e58a193e576570599c90c74c2f2e36aefc5503a7593f330a800fa8873d99b2/68747470733a2f2f706f7365722e707567782e6f72672f646176652d6c696464616d656e742f7068707374616e2d7068702d6c616e67756167652d657874656e73696f6e732f6c6963656e7365)](https://github.com/DaveLiddament/phpstan-php-language-extensions/blob/main/LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/4d0bbdfe8f2d4defd41031d9b2aa6d816f461298c5a99f74e24486f67b02910e/68747470733a2f2f706f7365722e707567782e6f72672f646176652d6c696464616d656e742f7068707374616e2d7068702d6c616e67756167652d657874656e73696f6e732f646f776e6c6f616473)](https://packagist.org/packages/dave-liddament/phpstan-php-language-extensions/stats)

[![Continuous Integration](https://github.com/DaveLiddament/phpstan-php-language-extensions/workflows/Full%20checks/badge.svg)](https://github.com/DaveLiddament/phpstan-php-language-extensions/actions)[![PHPStan max level](https://camo.githubusercontent.com/ecb39a33957e802f1f085f1debada1e99904e72b8d807e98991fb7f9660cb6d3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6d61782532306c6576656c2d627269676874677265656e2e737667)](https://github.com/DaveLiddament/phpstan-php-language-extensions/blob/main/phpstan.neon)

This is an extension for [PHPStan](https://phpstan.org) for adding analysis for [PHP Language Extensions](https://github.com/DaveLiddament/php-language-extensions).

**Language feature added:**

- [Friend](https://github.com/DaveLiddament/php-language-extensions#friend)
- [Injectable Version](https://github.com/DaveLiddament/php-language-extensions#injectableVersion)
- [MustUseResult](https://github.com/DaveLiddament/php-language-extensions#mustUseResult)
- [NamespaceVisibility](https://github.com/DaveLiddament/php-language-extensions#namespaceVisibility)
- [Package](https://github.com/DaveLiddament/php-language-extensions#package)
- [Restrict Trait To](https://github.com/DaveLiddament/php-language-extensions#retrictTraitTo)
- [Test Tag](https://github.com/DaveLiddament/php-language-extensions#testtag)

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

[](#installation)

To make the attributes available for your codebase use:

```
composer require dave-liddament/php-language-extensions
```

To use install PHPStan extension use:

```
composer require --dev dave-liddament/phpstan-php-language-extensions
```

If you are using [phpstan/extension-installer](https://github.com/phpstan/extension-installer) you're ready to go (but you might want to check out the configuration options)

 Manual installationIf you don't want to use `phpstan/extension-installer`, include rules.neon in your project's PHPStan config:

```
includes:
    - vendor/dave-liddament/phpstan-php-language-extensions/extension.neon

```

### Configuring

[](#configuring)

Some attributes, e.g. `#[package]`, might make testing difficult. It is possible to disable the checks for test code in one of two ways:

#### Exclude checks on class names ending with Test:

[](#exclude-checks-on-class-names-ending-with-test)

To exclude any checks from classes that where the name ends with `Test` add the following to the parameters section of your `phpstan.neon` file:

```
parameters:
  phpLanguageExtensions:
    mode: className
```

#### Exclude checks based on test namespace

[](#exclude-checks-based-on-test-namespace)

To exclude any checks from classes that are in the test namespace (e.g. `Acme\Test`) add the following to the parameters section of your `phpstan.neon` file:

```
parameters:
  phpLanguageExtensions:
    mode: namespace
    testNamespace: 'Acme\Test'
```

Contributing
------------

[](#contributing)

See [Contributing](CONTRIBUTING.md).

Demo project
------------

[](#demo-project)

See [PHP language extensions PHPStan demo](https://github.com/DaveLiddament/php-language-extensions-phpstan-demo) project.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance70

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 97.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 ~82 days

Recently: every ~100 days

Total

17

Last Release

170d ago

PHP version history (5 changes)0.1.0PHP ^8

0.3.0PHP &gt;=8.0 &lt;8.3

0.5.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

0.8.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

0.10.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

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

---

Top Contributors

[![DaveLiddament](https://avatars.githubusercontent.com/u/6787687?v=4)](https://github.com/DaveLiddament "DaveLiddament (129 commits)")[![doppynl](https://avatars.githubusercontent.com/u/814475?v=4)](https://github.com/doppynl "doppynl (2 commits)")[![dragosprotung](https://avatars.githubusercontent.com/u/1081073?v=4)](https://github.com/dragosprotung "dragosprotung (1 commits)")

---

Tags

PHPStanstatic analysisfriend attributenamespace visibility attribute

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/dave-liddament-phpstan-php-language-extensions/health.svg)

```
[![Health](https://phpackages.com/badges/dave-liddament-phpstan-php-language-extensions/health.svg)](https://phpackages.com/packages/dave-liddament-phpstan-php-language-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)[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.2M52](/packages/shipmonk-dead-code-detector)[szepeviktor/phpstan-wordpress

WordPress extensions for PHPStan

3287.8M898](/packages/szepeviktor-phpstan-wordpress)[staabm/phpstan-dba

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

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

PHPackages © 2026

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