slam/phpstan-laminas-framework

Laminas Framework 3 MVC controller plugin extension for PHPStan.

Maintainers

👁 Slam

Package info

github.com/Slamdunk/phpstan-laminas-framework

Type:phpstan-extension

pkg:composer/slam/phpstan-laminas-framework

Statistics

Installs: 299 670

Dependents: 6

Suggesters: 0

Stars: 19

Open Issues: 15

v2.1.1 2026-01-27 09:30 UTC

Requires

Suggests

None

Provides

None

Replaces

None

MIT 0b2fcb5bd5ff722db7a1b61541527a4400e1e703

  • Greg Bell <greg.woop@bitwombat.com.au>
  • Michael Gooden <me.woop@michaelgooden.net>
  • Filippo Tessarotto <zoeslam.woop@gmail.com>

README

👁 Latest Stable Version
👁 Downloads
👁 Integrate
👁 Code Coverage

This extension provides following features:

  1. Provide correct return type for $container->get() calls on containers of type \Laminas\ServiceManager\ServiceLocatorInterface, \Interop\Container\ContainerInterface or \Psr\Container\ContainerInterface
  2. Handle controller plugins that are called using magic __call() in subclasses of \Laminas\Mvc\Controller\AbstractController
  3. Provide correct return type for plugin method of AbstractController, FilterChain, PhpRenderer and ValidatorChain
  4. getApplication(), getRenderer(), getRequest() and getResponse() methods on Controllers, MvcEvents, View, ViewEvent and Application returns the real instance instead of type-hinted interfaces
  5. getView() method on \Laminas\View\Helper\AbstractHelper returns the real Renderer instance instead of type-hinted interface
  6. \Laminas\Stdlib\ArrayObject is configured as a Universal object crate
  7. Handle \Laminas\Stdlib\AbstractOptions magic properties

Installation

To use this extension, require it in Composer:

composer require --dev slam/phpstan-laminas-framework

If you also install phpstan/extension-installer then you're all set!

Configuration

This library already recognize built-in services and plugins.

You can opt in for more advanced analysis by providing the service manager from your own application:

parameters:
 laminasframework:
 serviceManagerLoader: tests/service-manager.php

For example, tests/service-manager.php would look something like this:

$app = \Laminas\Mvc\Application::init($config);
return $app->getServiceManager();