@@ -114,7 +114,7 @@ parameters:
114114 config_path: %currentWorkingDirectory%/config/test.php
115115```
116116
117- ** Note:** When you define ` dynamicConstantNames ` in your configuration, it ** replaces** the extension's default
117+ ** Note:** When you define ` dynamicConstantNames ` in your configuration, it ** replaces** the extension's default
118118constants.
119119To maintain the ` Yii2 ` constants recognition, you must include them explicitly along with your custom constants, as
120120shown above.
@@ -156,9 +156,70 @@ parameters:
156156 config_path: %currentWorkingDirectory%/config/web.php
157157```
158158
159+ ### PHPstan extension installer
160+
161+ You can use the ` phpstan-extension-installer ` to automatically install this extension.
162+
163+ To do this, you need to add the following configuration to your ` composer.json ` file:
164+
165+ ``` shell
166+ composer require --dev phpstan/extension-installer
167+ ```
168+
169+ or, add the following to your ` composer.json ` :
170+
171+ ``` json
172+ {
173+ "require-dev" : {
174+ "phpstan/extension-installer" : " ^1.4"
175+ },
176+ "config" : {
177+ "allow-plugins" : {
178+ "phpstan/extension-installer" : true
179+ }
180+ },
181+ }
182+ ```
183+
184+ ### Config ` yii2 ` application for PHPStan
185+
186+ To configure the ` yii2 ` application, you can use the ` yii2 ` section in your ` phpstan.neon ` file:
187+
188+ ``` neon
189+ parameters:
190+ yii2:
191+ # Path to your `Yii2` configuration file
192+ config_path: %currentWorkingDirectory%/config/test.php
193+ ```
194+
195+ ` config/test.php ` file should return an array with the application configuration, similar to the following:
196+
197+ ``` php
198+ <?php
199+
200+ declare(strict_types=1);
201+
202+ use yii2\extensions\localeurls\UrlLanguageManager;
203+
204+ return [
205+ 'components' => [
206+ // custom component
207+ 'helper' => [
208+ 'class' => \yii2\extensions\helper\Helper::class,
209+ ],
210+ // your component extended
211+ 'urlManager' => [
212+ 'class' => UrlLanguageManager::class,
213+ ],
214+ ],
215+ ];
216+ ```
217+
218+
219+
159220## Quality code
160221
161- [ ![ phpstan-level] ( https://img.shields.io/badge/PHPStan%20level-9 -blue )] ( https://github.com/yii2-extensions/phpstan/actions/workflows/static.yml )
222+ [ ![ phpstan-level] ( https://img.shields.io/badge/PHPStan%20level-max -blue )] ( https://github.com/yii2-extensions/phpstan/actions/workflows/static.yml )
162223[ ![ style-ci] ( https://github.styleci.io/repos/701347895/shield?branch=main )] ( https://github.styleci.io/repos/701347895?branch=main )
163224
164225## Testing
0 commit comments