https://github.com/slamdunk/phpstan-laminas-framework
Laminas Framework 3 extensions for PHPStan
https://github.com/slamdunk/phpstan-laminas-framework
laminas php phpstan static-analysis
Last synced: 6 months ago
JSON representation
Laminas Framework 3 extensions for PHPStan
- Host: GitHub
- URL: https://github.com/slamdunk/phpstan-laminas-framework
- Owner: Slamdunk
- License: mit
- Created: 2020-01-02T11:34:04.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-26T15:47:16.000Z (6 months ago)
- Last Synced: 2025-03-30T08:09:57.968Z (6 months ago)
- Topics: laminas, php, phpstan, static-analysis
- Language: PHP
- Homepage:
- Size: 227 KB
- Stars: 17
- Watchers: 4
- Forks: 12
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHPStan extension for Laminas Framework
[](https://packagist.org/packages/slam/phpstan-laminas-framework)
[](https://packagist.org/packages/slam/phpstan-laminas-framework)
[](https://github.com/Slamdunk/phpstan-laminas-framework/actions)
[](https://codecov.io/gh/Slamdunk/phpstan-laminas-framework?branch=master)* [PHPStan](https://phpstan.org/)
* [Laminas Framework](https://getlaminas.org/)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](https://phpstan.org/config-reference#universal-object-crates)
7. Handle `\Laminas\Stdlib\AbstractOptions` magic properties## Installation
To use this extension, require it in [Composer](https://getcomposer.org/):
```
composer require --dev slam/phpstan-laminas-framework
```If you also install [phpstan/extension-installer](https://github.com/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:
```neon
parameters:
laminasframework:
serviceManagerLoader: tests/service-manager.php
```For example, `tests/service-manager.php` would look something like this:
```php
$app = \Laminas\Mvc\Application::init($config);
return $app->getServiceManager();
```