Skip to content

Commit 474fb85

Browse files
committed
Update PHPStan in extractor
1 parent 9e032ef commit 474fb85

File tree

3 files changed

+46
-46
lines changed

3 files changed

+46
-46
lines changed

extractor/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"symfony/console": "^7.0.0",
55
"symfony/finder": "^7.0",
66
"nikic/php-parser": "^5",
7-
"phpstan/phpstan": "^1.5",
7+
"phpstan/phpstan": "^2.1",
88
"phpstan/extension-installer": "^1.1",
99
"phpstan/phpdoc-parser": "^1.4"
1010
},

extractor/composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extractor/extract.php

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
120120
if ($isUpdate) {
121121
require_once __DIR__ . '/../Php8StubsMap.php';
122122
$parts = explode('.', $updateFrom);
123+
124+
// @phpstan-ignore phpstanApi.constructor
123125
$map = new \PHPStan\Php8StubsMap((int) $parts[0] * 10000 + (int) ($parts[1] ?? 0) * 100 + (int) ($parts[2] ?? 0));
124126
$classes = $map->classes;
125127
$functions = $map->functions;
@@ -196,7 +198,7 @@ public function __construct(string $stubPath)
196198
$this->stubPath = $stubPath;
197199
}
198200

199-
public function enterNode(Node $node)
201+
public function enterNode(Node $node): ?int
200202
{
201203
if ($node instanceof Node\Stmt\Namespace_) {
202204
// pass
@@ -457,51 +459,49 @@ private function compareStatementsInNamespace(array $oldStmts, array $newStmts,
457459
}
458460
}
459461

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+
}
474475

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;
478478
}
479+
}
479480

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?
494482
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;
498494
}
499495

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+
}
503499
}
504500

501+
// todo has a constant been removed?
502+
503+
$old->stmts = $newStmtsToSet;
504+
505505
return [$old];
506506
}
507507

0 commit comments

Comments
 (0)