PHPackages                             erickskrauch/phpstan-yii2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. erickskrauch/phpstan-yii2

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

erickskrauch/phpstan-yii2
=========================

Yii2 extension for PHPStan

1269.5k—4.2%6[7 issues](https://github.com/erickskrauch/phpstan-yii2/issues)1PHPCI passing

Since Nov 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/erickskrauch/phpstan-yii2)[ Packagist](https://packagist.org/packages/erickskrauch/phpstan-yii2)[ RSS](/packages/erickskrauch-phpstan-yii2/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

Yii2 extension for PHPStan
==========================

[](#yii2-extension-for-phpstan)

An extension for [PHPStan](https://phpstan.org) providing types support and rules to work with the [Yii2 framework](https://www.yiiframework.com). Hardfork of [proget-hq/phpstan-yii2](https://github.com/proget-hq/phpstan-yii2).

[![Latest Version on Packagist](https://camo.githubusercontent.com/52e2340b849a696caad5bbd226166a7c8d5c4f107f4a71314630f5a474549c9f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f657269636b736b72617563682f7068707374616e2d796969322e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/erickskrauch/phpstan-yii2)[![Total Downloads](https://camo.githubusercontent.com/63386f09934ad8bd206c516f198a21867cadc100d1904ebb31d70db078cde8a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f657269636b736b72617563682f7068707374616e2d796969322e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/erickskrauch/phpstan-yii2/stats)[![Software License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/748d6fcda41f221af4f130cf9dbb809ac0708282a3532ef4083bc5874e9846cf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f657269636b736b72617563682f7068707374616e2d796969322f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/erickskrauch/phpstan-yii2/actions)

What does it do?
----------------

[](#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` and `ActiveQuery`.
- 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
------------

[](#installation)

To use this extension, require it in [Composer](https://getcomposer.org):

```
composer require --dev erickskrauch/phpstan-yii2
```

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

 Manual installationIf 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
-------------

[](#configuration)

You have to provide the path to the configuration file for your application. For [Advanced](https://github.com/yiisoft/yii2-app-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.*

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance24

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 55.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4787256?v=4)[ErickSkrauch](/maintainers/ErickSkrauch)[@erickskrauch](https://github.com/erickskrauch)

---

Top Contributors

[![erickskrauch](https://avatars.githubusercontent.com/u/4787256?v=4)](https://github.com/erickskrauch "erickskrauch (73 commits)")[![marmichalski](https://avatars.githubusercontent.com/u/57528542?v=4)](https://github.com/marmichalski "marmichalski (23 commits)")[![akondas](https://avatars.githubusercontent.com/u/8239917?v=4)](https://github.com/akondas "akondas (20 commits)")[![EtienneBruines](https://avatars.githubusercontent.com/u/3962174?v=4)](https://github.com/EtienneBruines "EtienneBruines (4 commits)")[![danieljonderko](https://avatars.githubusercontent.com/u/3042592?v=4)](https://github.com/danieljonderko "danieljonderko (3 commits)")[![Khartir](https://avatars.githubusercontent.com/u/5592420?v=4)](https://github.com/Khartir "Khartir (2 commits)")[![przepompownia](https://avatars.githubusercontent.com/u/11404453?v=4)](https://github.com/przepompownia "przepompownia (1 commits)")[![daniellz](https://avatars.githubusercontent.com/u/7566711?v=4)](https://github.com/daniellz "daniellz (1 commits)")[![dawidrylko](https://avatars.githubusercontent.com/u/11761319?v=4)](https://github.com/dawidrylko "dawidrylko (1 commits)")[![iVovolk](https://avatars.githubusercontent.com/u/7910672?v=4)](https://github.com/iVovolk "iVovolk (1 commits)")[![jrajamaki](https://avatars.githubusercontent.com/u/20750129?v=4)](https://github.com/jrajamaki "jrajamaki (1 commits)")[![particleflux](https://avatars.githubusercontent.com/u/3686454?v=4)](https://github.com/particleflux "particleflux (1 commits)")

---

Tags

phpstanphpstan-extensionyii2yii2-framework

### Embed Badge

![Health badge](/badges/erickskrauch-phpstan-yii2/health.svg)

```
[![Health](https://phpackages.com/badges/erickskrauch-phpstan-yii2/health.svg)](https://phpackages.com/packages/erickskrauch-phpstan-yii2)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
