@@ -120,6 +120,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
120
120
if ($ isUpdate ) {
121
121
require_once __DIR__ . '/../Php8StubsMap.php ' ;
122
122
$ parts = explode ('. ' , $ updateFrom );
123
+
124
+ // @phpstan-ignore phpstanApi.constructor
123
125
$ map = new \PHPStan \Php8StubsMap ((int ) $ parts [0 ] * 10000 + (int ) ($ parts [1 ] ?? 0 ) * 100 + (int ) ($ parts [2 ] ?? 0 ));
124
126
$ classes = $ map ->classes ;
125
127
$ functions = $ map ->functions ;
@@ -196,7 +198,7 @@ public function __construct(string $stubPath)
196
198
$ this ->stubPath = $ stubPath ;
197
199
}
198
200
199
- public function enterNode (Node $ node )
201
+ public function enterNode (Node $ node ): ? int
200
202
{
201
203
if ($ node instanceof Node \Stmt \Namespace_) {
202
204
// pass
@@ -457,51 +459,49 @@ private function compareStatementsInNamespace(array $oldStmts, array $newStmts,
457
459
}
458
460
}
459
461
460
- if ($ old ->stmts !== null ) {
461
- $ newStmtsToSet = $ untouchedStmts ;
462
- foreach ($ newMethods as $ stmt ) {
463
- $ methodName = $ stmt ->name ->toLowerString ();
464
- if (!array_key_exists ($ methodName , $ oldMethods )) {
465
- $ stmt ->attrGroups [] = new Node \AttributeGroup ([
466
- new Node \Attribute (
467
- new Node \Name \FullyQualified ('Since ' ),
468
- [new Node \Arg (new Node \Scalar \String_ ($ updateTo ))],
469
- ),
470
- ]);
471
- $ newStmtsToSet [] = $ stmt ;
472
- continue ;
473
- }
462
+ $ newStmtsToSet = $ untouchedStmts ;
463
+ foreach ($ newMethods as $ stmt ) {
464
+ $ methodName = $ stmt ->name ->toLowerString ();
465
+ if (!array_key_exists ($ methodName , $ oldMethods )) {
466
+ $ stmt ->attrGroups [] = new Node \AttributeGroup ([
467
+ new Node \Attribute (
468
+ new Node \Name \FullyQualified ('Since ' ),
469
+ [new Node \Arg (new Node \Scalar \String_ ($ updateTo ))],
470
+ ),
471
+ ]);
472
+ $ newStmtsToSet [] = $ stmt ;
473
+ continue ;
474
+ }
474
475
475
- foreach ($ this ->compareFunctions ($ oldMethods [$ methodName ], $ stmt , $ updateTo ) as $ functionStmt ) {
476
- $ newStmtsToSet [] = $ functionStmt ;
477
- }
476
+ foreach ($ this ->compareFunctions ($ oldMethods [$ methodName ], $ stmt , $ updateTo ) as $ functionStmt ) {
477
+ $ newStmtsToSet [] = $ functionStmt ;
478
478
}
479
+ }
479
480
480
- // todo has a method been removed?
481
-
482
- foreach ($ newConstants as $ stmt ) {
483
- $ namesKey = implode (', ' , array_map (static fn (Node \Const_ $ const ) => $ const ->name ->toString (), $ stmt ->consts ));
484
- if (!array_key_exists ($ namesKey , $ oldConstants )) {
485
- $ stmt ->attrGroups [] = new Node \AttributeGroup ([
486
- new Node \Attribute (
487
- new Node \Name \FullyQualified ('Since ' ),
488
- [new Node \Arg (new Node \Scalar \String_ ($ updateTo ))],
489
- ),
490
- ]);
491
- $ newStmtsToSet [] = $ stmt ;
492
- continue ;
493
- }
481
+ // todo has a method been removed?
494
482
495
- foreach ($ this ->compareConstants ($ oldConstants [$ namesKey ], $ stmt , $ updateTo ) as $ constantStmt ) {
496
- $ newStmtsToSet [] = $ constantStmt ;
497
- }
483
+ foreach ($ newConstants as $ stmt ) {
484
+ $ namesKey = implode (', ' , array_map (static fn (Node \Const_ $ const ) => $ const ->name ->toString (), $ stmt ->consts ));
485
+ if (!array_key_exists ($ namesKey , $ oldConstants )) {
486
+ $ stmt ->attrGroups [] = new Node \AttributeGroup ([
487
+ new Node \Attribute (
488
+ new Node \Name \FullyQualified ('Since ' ),
489
+ [new Node \Arg (new Node \Scalar \String_ ($ updateTo ))],
490
+ ),
491
+ ]);
492
+ $ newStmtsToSet [] = $ stmt ;
493
+ continue ;
498
494
}
499
495
500
- // todo has a constant been removed?
501
-
502
- $ old -> stmts = $ newStmtsToSet ;
496
+ foreach ( $ this -> compareConstants ( $ oldConstants [ $ namesKey ], $ stmt , $ updateTo ) as $ constantStmt ) {
497
+ $ newStmtsToSet [] = $ constantStmt ;
498
+ }
503
499
}
504
500
501
+ // todo has a constant been removed?
502
+
503
+ $ old ->stmts = $ newStmtsToSet ;
504
+
505
505
return [$ old ];
506
506
}
507
507
0 commit comments