This extension provides following features:
- Provide correct return type for
$container->get()calls on containers of type\Laminas\ServiceManager\ServiceLocatorInterface,\Interop\Container\ContainerInterfaceor\Psr\Container\ContainerInterface - Handle controller plugins that are called using magic
__call()in subclasses of\Laminas\Mvc\Controller\AbstractController - Provide correct return type for
pluginmethod ofAbstractController,FilterChain,PhpRendererandValidatorChain getApplication(),getRenderer(),getRequest()andgetResponse()methods on Controllers, MvcEvents, View, ViewEvent and Application returns the real instance instead of type-hinted interfacesgetView()method on\Laminas\View\Helper\AbstractHelperreturns the real Renderer instance instead of type-hinted interface\Laminas\Stdlib\ArrayObjectis configured as a Universal object crate- Handle
\Laminas\Stdlib\AbstractOptionsmagic properties
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!
Manual installation
If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:
includes:
- vendor/slam/phpstan-laminas-framework/extension.neon
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.phpFor example, tests/service-manager.php would look something like this:
$app = \Laminas\Mvc\Application::init($config);
return $app->getServiceManager();