Zend Framework 3 MVC controller plugin extension for PHPStan.
This repository has moved to Slamdunk/phpstan-laminas-framework.
This extension provides following features:
- Provide correct return types for
\Zend\ServiceManager\ServiceLocatorInterface::get()using real service instances
- Handle controller plugins that are called using magic
__call()in subclasses of
getResponse()methods on Controllers, MvcEvents, View, ViewEvent and Application returns the real instance instead of type-hinted interfaces
\Zend\View\Helper\AbstractHelperreturns the real Renderer instance instead of type-hinted interface
\Zend\Stdlib\ArrayObjectis configured as a Universal object crate
To use this extension, require it in Composer:
composer require --dev slam/phpstan-zend-framework
If you also install phpstan/extension-installer then you're all set!
If you don't want to use
phpstan/extension-installer, include extension.neon in your project's PHPStan config:
includes: - vendor/slam/phpstan-zend-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: zendframework: serviceManagerLoader: tests/service-manager.php
tests/service-manager.php would look something like this:
$app = \Zend\Mvc\Application::init($config); return $app->getServiceManager();