Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpstan Psr Container Laravel Package

bnf/phpstan-psr-container

PHPStan dynamic return type extension for PSR-11 ContainerInterface. Improves type inference for $container->get() so services are typed correctly during static analysis. Install via Composer and include extension.neon (or use phpstan/extension-installer).

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enables safer dependency resolution by eliminating false positives in PHPStan analysis for PSR-11 containers, reducing runtime errors caused by invalid service IDs.
  • Supports the decision to invest in static analysis tooling for DI container usage, avoiding custom rule development and leveraging existing PHPStan infrastructure.
  • Facilitates refactoring of service dependencies in large codebases by providing accurate type inference for container.get() calls, improving developer confidence.
  • Validates the "build vs buy" choice by offering a specialized solution for container-aware analysis instead of building internal tooling from scratch.
  • Helps enforce consistent service contracts across teams, especially in microservices or modular architectures where container usage is pervasive.
  • Reduces maintenance overhead by ensuring compatibility with the latest PHPStan versions (now supporting PHPStan 2.x), aligning with modern tooling ecosystems and reducing future migration risks.

When to Consider This Package

Adopt this package when your project uses a PSR-11-compliant container (e.g., Symfony, Laravel, Zend Expressive) and relies on ContainerInterface::get() for dependency resolution. It is ideal when:

  • Your team uses PHPStan for static analysis but encounters frequent false positives around container service resolution.
  • You are scaling a codebase where service contracts need stricter validation.
  • You want to future-proof your toolchain by ensuring compatibility with the latest PHPStan versions (now explicitly supporting PHPStan 2.x).

Avoid if:

  • Your application does not use PSR-11 containers (e.g., custom DI implementations).
  • PHPStan is not part of your toolchain.
  • Your framework has native static analysis tools specifically for its container (e.g., Laravel’s own container analysis extensions).
  • Your project is small enough that manual code reviews suffice for dependency checks.

How to Pitch It (Stakeholders)

For executives: "This extension significantly reduces production bugs related to service resolution by catching errors during development via PHPStan. It lowers debugging time and accelerates release cycles by ensuring service dependencies are correctly defined before deployment—without requiring new infrastructure or developer training. The minimal integration effort (just adding the package) delivers high ROI. Additionally, its compatibility with PHPStan 2.x ensures long-term alignment with modern tooling, reducing future migration risks and maintenance overhead."

For engineering teams: "This package eliminates false positives in PHPStan for PSR-11 containers, giving developers confidence in their dependency resolution. With support for the latest PHPStan versions, it future-proofs your static analysis setup while requiring zero additional configuration. Ideal for large codebases or microservices where container validation is critical."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport