Skip to content

Commit 9c7e3a8

Browse files
committed
Apply fixed review coderabbitai nitpick comments.
1 parent 677b63a commit 9c7e3a8

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed

.gitignore

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
#code coverage
2-
/code_coverage
2+
code_coverage
3+
4+
# composer
5+
composer.lock
36

47
#copilot
58
copilot
69

7-
# composer vendor dir
8-
/vendor
9-
/composer.lock
10-
1110
#node_modules
12-
/node_modules
11+
node_modules
1312

1413
# phpstorm project files
1514
.idea
1615

1716
# phpunit
18-
.phpunit.cache
19-
.phpunit.result.cache
20-
phpunit.phar
21-
phpunit.xml.*
17+
.phpunit.*
18+
phpunit.*
19+
20+
# vendor directory
21+
vendor
2222

2323
# vscode
2424
.vscode
2525

26-
#yii3 config packages
27-
/config/packages
28-
2926
# windows thumbnail cache
3027
Thumbs.db

docs/configuration.md

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ parameters:
1818
paths:
1919
- src
2020
21-
tmpDir: %currentWorkingDirectory%/runtime
22-
21+
tmpDir: %currentWorkingDirectory%/runtime
22+
2323
yii2:
2424
config_path: config/phpstan-config.php
2525
```
@@ -38,7 +38,7 @@ parameters:
3838
- config/
3939
- runtime/
4040
- vendor/
41-
- web/assets/
41+
- web/assets/
4242
4343
level: 6
4444
@@ -107,7 +107,7 @@ parameters:
107107
- commands
108108
- console
109109
110-
tmpDir: %currentWorkingDirectory%/runtime
110+
tmpDir: %currentWorkingDirectory%/runtime
111111
112112
yii2:
113113
config_path: config/phpstan-console-config.php
@@ -167,14 +167,14 @@ return [
167167
'class' => \yii\db\Connection::class,
168168
'dsn' => 'mysql:host=localhost;dbname=test',
169169
],
170-
170+
171171
// User component with identity class
172172
'user' => [
173173
'class' => \yii\web\User::class,
174174
'identityClass' => \app\models\User::class,
175175
'loginUrl' => ['/site/login'],
176176
],
177-
177+
178178
// Mailer
179179
'mailer' => [
180180
'class' => \yii\symfonymailer\Mailer::class,
@@ -183,19 +183,19 @@ return [
183183
'host' => 'localhost',
184184
],
185185
],
186-
186+
187187
// Cache
188188
'cache' => [
189189
'class' => \yii\caching\FileCache::class,
190190
'cachePath' => '@runtime/cache',
191191
],
192-
192+
193193
// Custom components
194194
'paymentService' => [
195195
'class' => \app\services\PaymentService::class,
196196
'apiKey' => 'test-key',
197197
],
198-
198+
199199
// URL Manager
200200
'urlManager' => [
201201
'class' => \yii\web\UrlManager::class,
@@ -274,16 +274,16 @@ class UserController
274274
{
275275
// ✅ PHPStan knows this is User<app\models\User>
276276
$user = Yii::$app->user;
277-
277+
278278
// ✅ PHPStan knows identity is app\models\User
279279
$identity = $user->identity;
280-
280+
281281
// ✅ PHPStan knows this is Repository<app\models\User>
282282
$repository = Yii::$app->userRepository;
283-
283+
284284
// ✅ PHPStan knows this is Collection<app\models\Post>
285285
$collection = Yii::$app->postCollection;
286-
286+
287287
return $this->render('profile', ['user' => $identity]);
288288
}
289289
}
@@ -304,24 +304,24 @@ use yii\base\Component;
304304

305305
/**
306306
* Generic repository component.
307-
*
307+
*
308308
* @template T of \yii\db\ActiveRecord
309309
*/
310310
class Repository extends Component
311311
{
312-
/**
312+
/**
313313
* @phpstan-var class-string<T>
314314
*/
315315
public string $modelClass;
316-
316+
317317
/**
318318
* @phpstan-return T|null
319319
*/
320320
public function findOne(int $id): \yii\db\ActiveRecord|null
321321
{
322322
return $this->modelClass::findOne($id);
323323
}
324-
324+
325325
/**
326326
* @phpstan-return T[]
327327
*/
@@ -343,29 +343,29 @@ use yii\base\Component;
343343

344344
/**
345345
* Generic collection component.
346-
*
346+
*
347347
* @template T
348348
*/
349349
class Collection extends Component
350350
{
351-
/**
351+
/**
352352
* @phpstan-var class-string<T>
353353
*/
354354
public string $elementType;
355-
356-
/**
355+
356+
/**
357357
* @phpstan-var T[]
358358
*/
359359
private array $items = [];
360-
360+
361361
/**
362362
* @phpstan-param T $item
363363
*/
364364
public function add($item): void
365365
{
366366
$this->items[] = $item;
367367
}
368-
368+
369369
/**
370370
* @phpstan-return T[]
371371
*/
@@ -438,19 +438,19 @@ return [
438438
// Interface to implementation mapping
439439
\Psr\Log\LoggerInterface::class => \Monolog\Logger::class,
440440
\app\contracts\PaymentInterface::class => \app\services\StripePayment::class,
441-
441+
442442
// Service definitions
443443
'logger' => [
444444
'class' => \Monolog\Logger::class,
445445
['name' => 'app'],
446446
],
447-
447+
448448
// Closure definitions
449449
'eventDispatcher' => function() {
450450
return new \app\services\EventDispatcher();
451451
},
452452
],
453-
453+
454454
'singletons' => [
455455
// Singleton services
456456
\app\services\CacheManager::class => \app\services\CacheManager::class,
@@ -480,15 +480,15 @@ parameters:
480480
- vendor/
481481
482482
level: 8
483-
483+
484484
paths:
485485
- src
486486
- controllers
487487
- models
488488
- widgets
489489
- components
490490
491-
tmpDir: %currentWorkingDirectory%/runtime
491+
tmpDir: %currentWorkingDirectory%/runtime
492492
493493
yii2:
494494
config_path: config/phpstan-config.php
@@ -502,7 +502,7 @@ parameters:
502502
reportAnyTypeWideningInVarTag: true
503503
reportPossiblyNonexistentConstantArrayOffset: true
504504
reportPossiblyNonexistentGeneralArrayOffset: true
505-
505+
506506
ignoreErrors:
507507
# Ignore specific errors
508508
- '#Call to an undefined method.*#'
@@ -512,7 +512,7 @@ parameters:
512512
### Performance optimization
513513

514514
```neon
515-
parameters:
515+
parameters:
516516
# Bootstrap optimization
517517
bootstrapFiles:
518518
- vendor/autoload.php
@@ -563,13 +563,15 @@ This will work with basic type inference but won't have custom component types.
563563
For projects with both web and console applications:
564564

565565
### Project structure
566+
566567
```text
567568
phpstan-web.neon # Web-specific configuration
568569
phpstan-console.neon # Console-specific configuration
569570
phpstan.neon # Base configuration
570571
```
571572

572573
### Base configuration
574+
573575
```neon
574576
# phpstan.neon
575577
includes:
@@ -582,6 +584,7 @@ parameters:
582584
```
583585

584586
### Web configuration
587+
585588
```neon
586589
# phpstan-web.neon
587590
includes:
@@ -599,6 +602,7 @@ parameters:
599602
```
600603

601604
### Console configuration
605+
602606
```neon
603607
# phpstan-console.neon
604608
includes:
@@ -614,11 +618,12 @@ parameters:
614618
```
615619

616620
### Usage
621+
617622
```bash
618623
# Analyze web application
619624
vendor/bin/phpstan analyse -c phpstan-web.neon
620625

621-
# Analyze console application
626+
# Analyze console application
622627
vendor/bin/phpstan analyse -c phpstan-console.neon
623628
```
624629

0 commit comments

Comments
 (0)