erickskrauch / phpstan-yii2
Yii2 extension for PHPStan
Installs: 11 094
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 4
Open Issues: 6
Requires
- php: ^7.4 || ^8.0
- nikic/php-parser: ^4 || ^5
- phpstan/phpstan: ^1.10
- yiisoft/yii2: ~2.0.36
Requires (Dev)
- ely/php-code-style: ^1
- ergebnis/composer-normalize: ^2.28
- friendsofphp/php-cs-fixer: ^3.13
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: 1.11.x-dev
- phpstan/phpstan-phpunit: ^1
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-10-28 20:48:01 UTC
README
An extension for PHPStan providing types support and rules to work with the Yii2 framework. Hardfork of proget-hq/phpstan-yii2.
What does it do?
- Provides stub files for better analysis of array shapes.
- Provide array shape analyse for
Yii:createObject()
. - Provide analyse for the last array argument of the
yii\base\Configurable
class constructor. - Mark
YII_*
constants as dynamic. - Significantly improves support for
ActiveRecord
andActiveQuery
. - Provides correct return type for
Yii::$container->get('service_id')
method. - Provides correct return type for
Yii::$app->request->headers->get('authorization')
method based on the$first
parameter. - Provides reflection extension for
BaseObject
's getters and setters.
Installation
To use this extension, require it in Composer:
composer require --dev erickskrauch/phpstan-yii2
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/erickskrauch/phpstan-yii2/extension.neon
- vendor/erickskrauch/phpstan-yii2/rules.neon
Configuration
You have to provide the path to the configuration file for your application. For Advanced project template your path might look like this:
parameters: yii2: config_path: common/config/main.php
You may want to create a separate configuration file for PHPStan describing the services available throughout the application. But usually, common
is sufficient, because it contains all the services universally available in any module of the application.