PHPackages                             syntatis/phpstan-psr-11 - 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. syntatis/phpstan-psr-11

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

syntatis/phpstan-psr-11
=======================

PHPStan dynamic return type extension for PSR-11

v0.1.0(9mo ago)22.2k↓100%[2 PRs](https://github.com/syntatis/phpstan-psr-11/pulls)MITPHPPHP ^7.4 || ^8.0CI passing

Since Aug 3Pushed 2mo agoCompare

[ Source](https://github.com/syntatis/phpstan-psr-11)[ Packagist](https://packagist.org/packages/syntatis/phpstan-psr-11)[ RSS](/packages/syntatis-phpstan-psr-11/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (11)Versions (5)Used By (0)

🕵️ phpstan-psr-11
=================

[](#️--phpstan-psr-11)

[![ci](https://github.com/syntatis/phpstan-psr-11/actions/workflows/ci.yml/badge.svg)](https://github.com/syntatis/phpstan-psr-11/actions/workflows/ci.yml)[![Packagist Dependency Version](https://camo.githubusercontent.com/e29b7c2cb7f5b7268c5e97271a11d515effce29d70fb728c8ffd0953f4226dba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f73796e74617469732f7068707374616e2d7073722d31312f7068703f636f6c6f723d253233374138364238)](https://camo.githubusercontent.com/e29b7c2cb7f5b7268c5e97271a11d515effce29d70fb728c8ffd0953f4226dba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f73796e74617469732f7068707374616e2d7073722d31312f7068703f636f6c6f723d253233374138364238)[![Packagist Dependency Version](https://camo.githubusercontent.com/bff23d3043d6d2f3eab44e766052d1552718b626e2efc5a2f9025fd8cb2902bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f73796e74617469732f7068707374616e2d7073722d31312f7068707374616e2532467068707374616e)](https://camo.githubusercontent.com/bff23d3043d6d2f3eab44e766052d1552718b626e2efc5a2f9025fd8cb2902bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f73796e74617469732f7068707374616e2d7073722d31312f7068707374616e2532467068707374616e)

> PHPStan rules to resolve value type from PSR-11 `ContainerInterface`.

The `get` method in the `ContainerInterface` interface return type is `mixed`. This is not really useful for static analysis tools like PHPStan. Since it cannot infer the type of the service. You will need to add a PHPDoc comment to the variable to help PHPStan infer the type or check the type of the service at runtime with `is_a` or `instanceof` or use assertion [to narrow down the type](https://phpstan.org/writing-php-code/narrowing-types).

For example:

```
use Bar\Service;
use Psr\Container\ContainerInterface;

class Foo
{
    public function __construct(ContainerInterface $container)
    {
        $service = $container->get(Service::class);

        // PHPStan cannot infer the type of `$service`.
        // Check the type of the service at runtime.
        if ($service instanceof Service) {
        }
    }
}
```

This package adds a return type to the `get` method, based on the requested service. You do not need to add PHPDoc comments or check the type of the service at runtime.

For example:

```
use Bar\Service;
use Psr\Container\ContainerInterface;

class Foo
{
    public function __construct(ContainerInterface $container)
    {
        $service = $container->get(Service::class);
        // PHPStan inferred the type `$service` as Bar\Service.
    }
}
```

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

[](#installation)

Install the package with Composer:

```
composer require --dev syntatis/phpstan-psr-11

```

Include `extension.neon` in your project's PHPStan config:

```
includes:
    - vendor/syntatis/phpstan-psr-11/extension.neon

```

Or, use [`phpstan/extension-installer`](https://github.com/phpstan/extension-installer).

Configuration
-------------

[](#configuration)

By default, the rule will check `Psr\Container\ContainerInterface`. If you've scoped or prefixed the interface, you can configure the rule to check the interface by providing the interface name in the configuration. For example:

```
parameters:
    syntatis:
        psr-11: 'Acme\Psr\Container\ContainerInterface'
```

Credits
-------

[](#credits)

This packaged is based on [phpstan-container-extension](https://packagist.org/packages/phil-nelson/phpstan-container-extension) by [Phil Nelson](https://github.com/phil-nelson).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance74

Regular maintenance activity

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 62.5% 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

Unknown

Total

1

Last Release

280d ago

### Community

Maintainers

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

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![tfirdaus](https://avatars.githubusercontent.com/u/2067467?v=4)](https://github.com/tfirdaus "tfirdaus (3 commits)")

---

Tags

composer-packagephpstan-extensionpsr-11PSR-11PHPStandevstaticservice provider

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/syntatis-phpstan-psr-11/health.svg)

```
[![Health](https://phpackages.com/badges/syntatis-phpstan-psr-11/health.svg)](https://phpackages.com/packages/syntatis-phpstan-psr-11)
```

###  Alternatives

[symfony/contracts

A set of abstractions extracted out of the Symfony components

3.9k64.6M103](/packages/symfony-contracts)[bnf/phpstan-psr-container

PHPStan dynamic return type extension for PSR-11 ContainerInterface

133.5M53](/packages/bnf-phpstan-psr-container)[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[laminas/laminas-servicemanager

Factory-Driven Dependency Injection Container

15955.1M694](/packages/laminas-laminas-servicemanager)

PHPackages © 2026

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