slam / phpstan-laminas-framework
Laminas Framework 3 MVC controller plugin extension for PHPStan.
Fund package maintenance!
Slamdunk
paypal.me/filippotessarotto
Installs: 183 125
Dependents: 6
Suggesters: 0
Security: 0
Stars: 16
Watchers: 5
Forks: 12
Open Issues: 10
Type:phpstan-extension
Requires
- php: ~8.2.0 || ~8.3.0 || ~8.4.0
- phpstan/phpstan: ^2.0.2
Requires (Dev)
- laminas/laminas-filter: ^2.39.0
- laminas/laminas-form: ^3.21.0
- laminas/laminas-hydrator: ^4.16.0
- laminas/laminas-i18n: ^2.29.0
- laminas/laminas-inputfilter: ^2.31.0
- laminas/laminas-mvc: ^3.8.0
- laminas/laminas-paginator: ^2.19.0
- laminas/laminas-validator: ^2.64.1
- phpstan/phpstan-deprecation-rules: ^2
- phpstan/phpstan-phpunit: ^2.0.1
- phpunit/phpunit: ^11.4.3
- slam/php-cs-fixer-extensions: ^3.11.1
Conflicts
- laminas/laminas-filter: <2.37
- laminas/laminas-form: <3.20
- laminas/laminas-hydrator: <4.15
- laminas/laminas-i18n: <2.28
- laminas/laminas-inputfilter: <2.30
- laminas/laminas-log: <2.16
- laminas/laminas-mail: <2.25
- laminas/laminas-mvc: <3.7
- laminas/laminas-paginator: <2.18
- laminas/laminas-validator: <2.64
README
This extension provides following features:
- Provide correct return type for
$container->get()
calls on containers of type\Laminas\ServiceManager\ServiceLocatorInterface
,\Interop\Container\ContainerInterface
or\Psr\Container\ContainerInterface
- Handle controller plugins that are called using magic
__call()
in subclasses of\Laminas\Mvc\Controller\AbstractController
- Provide correct return type for
plugin
method ofAbstractController
,FilterChain
,PhpRenderer
andValidatorChain
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\AbstractHelper
returns the real Renderer instance instead of type-hinted interface\Laminas\Stdlib\ArrayObject
is configured as a Universal object crate- 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!
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
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();