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

Technical Evaluation

Architecture fit: The package continues to integrate seamlessly with Laravel’s PSR-11 compliant container, enhancing static analysis for get()/has() calls while aligning with PHPStan’s workflow. The explicit compatibility with PHPStan 2.x (via PR #7) strengthens its fit for modern Laravel projects using PHPStan. However, Laravel-specific customizations (e.g., dynamic bindings, closures in bind()/singleton()) remain unvalidated. The package’s reliance on PSR-11 adherence may still require manual PHPDoc annotations for non-standard container setups.

Integration feasibility: High, but now explicitly supported for PHPStan 2.x (per PR #7), reducing versioning risks. Installation remains trivial via Composer, and the extension-installer link in the README (PR #6) improves discoverability. However, the low adoption (13 stars) and unknown repository status persist as concerns, particularly for documentation and long-term support.

Technical risk: Reduced to low for PHPStan 2.x users due to explicit compatibility. However, risks remain for:

  • Laravel-specific edge cases (e.g., closures in bindings, custom factories).
  • GPL-2.0 license for proprietary projects.
  • Undocumented limitations in complex service resolution (e.g., nested containers, conditional bindings).

Key questions:

  • Are there test cases for Laravel’s bind()/singleton() with closures or dynamic keys?
  • How does the package handle PHPStan 2.x’s breaking changes (e.g., new rule sets, configuration shifts)?
  • What is the maintenance cadence (e.g., response to issues, PHPStan 3.x readiness)?
  • Are there performance implications for large container graphs?

Integration Approach

Stack fit: Excellent for Laravel projects using PHPStan 2.x. The package’s native PSR-11 alignment and explicit PHPStan 2.x support make it a low-friction addition to existing static analysis pipelines. No breaking changes are introduced in 1.1.0, ensuring backward compatibility.

Migration path:

  1. Update PHPStan to ^2.0 (if not already) and install the package:
    composer require --dev bnf/phpstan-psr-container ^1.1.0
    
  2. Add to phpstan.neon:
    extensions:
        bnf\phpstan\psrContainer\Extension
    
  3. For custom services, supplement with PHPDoc types or container-specific annotations.
  4. Validate against new PHPStan 2.x rules (e.g., stricter type narrowing).

Compatibility: Confirmed for PHPStan 2.x; no Laravel version constraints are mentioned. Sequencing:

  • Install after PHPStan 2.x upgrade to avoid version conflicts.
  • Test in a staging environment due to undocumented Laravel-specific behaviors.

Operational Impact

Maintenance: Minimal ongoing effort expected, but monitor for PHPStan 3.x compatibility. The package’s simplicity (PSR-11 focus) reduces maintenance overhead.

Support: Limited by low adoption and no public issue tracker link. Users must rely on GitHub discussions or community contributions (e.g., recent PRs from new maintainers). Consider internal documentation for Laravel-specific workarounds.

Scaling: No scalability concerns identified. Performance impact is negligible for typical Laravel container sizes.

Failure modes:

  • False positives in type inference for non-PSR-11 container setups (e.g., Laravel’s dynamic bindings).
  • Configuration drift if PHPStan or Laravel updates break compatibility (e.g., PHPStan 3.x).
  • License compliance risks for proprietary projects.

Ramp-up:

  • 1–2 hours for basic integration (installation + config).
  • Additional time may be needed for custom service annotations or troubleshooting Laravel-specific edge cases.
  • Recommended: Start with a subset of critical services to validate accuracy before full adoption.
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