PHPackages                             php-standard-library/phpstan-extension - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. php-standard-library/phpstan-extension

ActivePhpstan-extension[PSR &amp; Standards](/categories/psr-standards)

php-standard-library/phpstan-extension
======================================

PHPStan PSL extension

2.1.0(3mo ago)221.3M↓50.3%7[14 issues](https://github.com/php-standard-library/phpstan-extension/issues)[6 PRs](https://github.com/php-standard-library/phpstan-extension/pulls)13MITPHPPHP ^7.4 || ^8.0CI passing

Since Jun 10Pushed 1w ago4 watchersCompare

[ Source](https://github.com/php-standard-library/phpstan-extension)[ Packagist](https://packagist.org/packages/php-standard-library/phpstan-extension)[ RSS](/packages/php-standard-library-phpstan-extension/feed)WikiDiscussions 2.0.x Synced 2d ago

READMEChangelog (8)Dependencies (16)Versions (16)Used By (13)

PHPStan PSL extension
=====================

[](#phpstan-psl-extension)

[![Build](https://github.com/php-standard-library/phpstan-extension/workflows/Build/badge.svg)](https://github.com/php-standard-library/phpstan-extension/actions)[![Latest Stable Version](https://camo.githubusercontent.com/1914e48d30af24c8caf15d50efa64d0920328d0b0e110d737612493e6f5645eb/68747470733a2f2f706f7365722e707567782e6f72672f7068702d7374616e646172642d6c6962726172792f7068707374616e2d657874656e73696f6e2f762f737461626c65)](https://packagist.org/packages/php-standard-library/phpstan-extension)[![License](https://camo.githubusercontent.com/cabbb94a143fae71fb25086939804a19c44fb143424b0579af5ee21ec424c84f/68747470733a2f2f706f7365722e707567782e6f72672f7068702d7374616e646172642d6c6962726172792f7068707374616e2d657874656e73696f6e2f6c6963656e7365)](https://packagist.org/packages/php-standard-library/phpstan-extension)

- [PHPStan](https://phpstan.org/)
- [PSL](https://github.com/php-standard-library/php-standard-library)

Description
-----------

[](#description)

The main goal of this extension is to help PHPStan to detect the types after using `Psl\Type\shape`.

Given the following example:

```
use Psl\Type;

$specification = Type\shape([
    'name' => Type\string(),
    'age' => Type\int(),
    'location' => Type\optional(Type\shape([
        'city' => Type\string(),
        'state' => Type\string(),
        'country' => Type\string(),
    ]))
]);

$input = $specification->coerce($_GET['user']);
```

PHPStan assumes that `$input` is of type `array`.

If we enable the extension, you will get a more specific and correct type of `array{name: string, age: int, location?: array{city: string, state: string, country: string}}`.

Besides coerce, this extension also supports `matches()` and `assert()` methods.

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

[](#installation)

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

```
composer require --dev php-standard-library/phpstan-extension

```

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

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

```
includes:
    - vendor/php-standard-library/phpstan-extension/extension.neon

```

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance77

Regular maintenance activity

Popularity50

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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 ~137 days

Recently: every ~27 days

Total

11

Last Release

108d ago

Major Versions

1.1.x-dev → 2.0.02024-11-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/104888?v=4)[Ondřej Mirtes](/maintainers/ondrejmirtes)[@ondrejmirtes](https://github.com/ondrejmirtes)

![](https://www.gravatar.com/avatar/8489d7c85bfa7c637b8e13484f3f659652aea0568b6e7f9e66edeb0649b5a2f1?d=identicon)[azjezz](/maintainers/azjezz)

---

Top Contributors

[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (30 commits)")[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (4 commits)")[![BackEndTea](https://avatars.githubusercontent.com/u/14289961?v=4)](https://github.com/BackEndTea "BackEndTea (3 commits)")[![simPod](https://avatars.githubusercontent.com/u/327717?v=4)](https://github.com/simPod "simPod (1 commits)")[![azjezz](https://avatars.githubusercontent.com/u/29315886?v=4)](https://github.com/azjezz "azjezz (1 commits)")[![YspMark](https://avatars.githubusercontent.com/u/55830693?v=4)](https://github.com/YspMark "YspMark (1 commits)")[![devnix](https://avatars.githubusercontent.com/u/1777519?v=4)](https://github.com/devnix "devnix (1 commits)")[![shirshir](https://avatars.githubusercontent.com/u/660457?v=4)](https://github.com/shirshir "shirshir (1 commits)")

###  Code Quality

TestsPHPUnit

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-standard-library-phpstan-extension/health.svg)

```
[![Health](https://phpackages.com/badges/php-standard-library-phpstan-extension/health.svg)](https://phpackages.com/packages/php-standard-library-phpstan-extension)
```

###  Alternatives

[rector/rector

Instant Upgrade and Automated Refactoring of any PHP code

10.4k139.2M9.2k](/packages/rector-rector)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[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.

4853.5M91](/packages/shipmonk-dead-code-detector)[tomasvotruba/cognitive-complexity

PHPStan rules to measure cognitive complexity of your classes and methods

1635.6M288](/packages/tomasvotruba-cognitive-complexity)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M344](/packages/drupal-core-dev)

PHPackages © 2026

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