Skip to content

Commit 3e75799

Browse files
committed
Add named arguments to more constructor, static, and function calls
Improve readability of calls with ambiguous boolean/null positional arguments across 16 files: - ThrowPoint, InternalThrowPoint, SimpleThrowPoint: explicit/canContainAnyThrowable - InternalError: trace/traceAsString/shouldReportBug across all call sites - ScopeContext: classReflection/traitReflection - ExpressionContext: isDeep/inAssignRightSideVariableName/inAssignRightSideExpr - ExportedTraitUseAdaptation: newModifier/newName/insteadOfs - ConstantResolver: phpVersion/composerPhpVersionFactory/container - TypeUtils::map(): inspectIntersections/stopOnUnmatched - NameScope: className https://claude.ai/code/session_01Tf5zvkNk4w3dp6TU7UM8b6
1 parent bf2995d commit 3e75799

16 files changed

Lines changed: 31 additions & 31 deletions

‎src/Analyser/AnalyserResultFinalizer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function finalize(AnalyserResult $analyserResult, bool $onlyFiles, bool $
8787
sprintf('running CollectedDataNode rule %s', get_class($rule)),
8888
InternalError::prepareTrace($t),
8989
$t->getTraceAsString(),
90-
true,
90+
shouldReportBug: true,
9191
);
9292
continue;
9393
}

‎src/Analyser/ConstantResolver.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public function resolveConstantType(string $constantName, Type $constantType): T
419419
$phpdocTypes = $this->dynamicConstantNames[$constantName];
420420
if ($this->container !== null) {
421421
$typeStringResolver = $this->container->getByType(TypeStringResolver::class);
422-
return $typeStringResolver->resolve($phpdocTypes, new NameScope(null, [], null));
422+
return $typeStringResolver->resolve($phpdocTypes, new NameScope(null, [], className: null));
423423
}
424424
return $constantType;
425425
}

‎src/Analyser/ExpressionContext.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ private function __construct(
1717

1818
public static function createTopLevel(): self
1919
{
20-
return new self(false, null, null);
20+
return new self(isDeep: false, inAssignRightSideVariableName: null, inAssignRightSideExpr: null);
2121
}
2222

2323
public static function createDeep(): self
2424
{
25-
return new self(true, null, null);
25+
return new self(isDeep: true, inAssignRightSideVariableName: null, inAssignRightSideExpr: null);
2626
}
2727

2828
public function enterDeep(): self

‎src/Analyser/InternalThrowPoint.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function createExplicit(MutatingScope $scope, Type $type, Node $no
4747
*/
4848
public static function createImplicit(MutatingScope $scope, Node $node): self
4949
{
50-
return new self($scope, new ObjectType(Throwable::class), $node, false, true);
50+
return new self($scope, new ObjectType(Throwable::class), $node, explicit: false, canContainAnyThrowable: true);
5151
}
5252

5353
public static function createFromPublic(ThrowPoint $throwPoint): self

‎src/Analyser/ScopeContext.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ private function __construct(
1919
/** @api */
2020
public static function create(string $file): self
2121
{
22-
return new self($file, null, null);
22+
return new self($file, classReflection: null, traitReflection: null);
2323
}
2424

2525
public function beginFile(): self
2626
{
27-
return new self($this->file, null, null);
27+
return new self($this->file, classReflection: null, traitReflection: null);
2828
}
2929

3030
public function enterClass(ClassReflection $classReflection): self
@@ -35,7 +35,7 @@ public function enterClass(ClassReflection $classReflection): self
3535
if ($classReflection->isTrait()) {
3636
throw new ShouldNotHappenException();
3737
}
38-
return new self($this->file, $classReflection, null);
38+
return new self($this->file, $classReflection, traitReflection: null);
3939
}
4040

4141
public function enterTrait(ClassReflection $traitReflection): self

‎src/Analyser/ThrowPoint.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function createExplicit(Scope $scope, Type $type, Node $node, bool
4040
*/
4141
public static function createImplicit(Scope $scope, Node $node): self
4242
{
43-
return new self($scope, new ObjectType(Throwable::class), $node, false, true);
43+
return new self($scope, new ObjectType(Throwable::class), $node, explicit: false, canContainAnyThrowable: true);
4444
}
4545

4646
public function getScope(): Scope

‎src/Command/AnalyseCommand.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
401401
$internalError->getContextDescription(),
402402
$internalError->getTrace(),
403403
$internalError->getTraceAsString(),
404-
$internalError->shouldReportBug(),
404+
shouldReportBug: $internalError->shouldReportBug(),
405405
), false];
406406
}
407407
foreach ($analysisResult->getFileSpecificErrors() as $fileSpecificError) {
@@ -431,7 +431,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
431431
sprintf('analysing file %s', $fileSpecificError->getTraitFilePath() ?? $fileSpecificError->getFilePath()),
432432
$metadata[InternalError::STACK_TRACE_METADATA_KEY] ?? [],
433433
$metadata[InternalError::STACK_TRACE_AS_STRING_METADATA_KEY] ?? null,
434-
true,
434+
shouldReportBug: true,
435435
), !$hasStackTrace];
436436
}
437437

@@ -453,7 +453,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
453453
$internalError->getContextDescription(),
454454
$internalError->getTrace(),
455455
$internalError->getTraceAsString(),
456-
$internalError->shouldReportBug(),
456+
shouldReportBug: $internalError->shouldReportBug(),
457457
);
458458
}
459459

‎src/Command/FixerApplication.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ private function analyse(
522522
'running PHPStan Pro worker',
523523
$trace,
524524
$traceAsString,
525-
false,
525+
shouldReportBug: false,
526526
)],
527527
]]);
528528
});

‎src/Command/FixerWorkerCommand.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ function (array $errors, array $locallyIgnoredErrors, array $analysedFiles) use
281281
new InternalError(
282282
'Internal error occurred',
283283
'running analyser in PHPStan Pro worker',
284-
[],
285-
null,
286-
false,
284+
trace: [],
285+
traceAsString: null,
286+
shouldReportBug: false,
287287
),
288288
],
289289
]]);
@@ -349,7 +349,7 @@ private function transformErrorIntoInternalError(Error $error): InternalError
349349
sprintf('analysing file %s', $error->getTraitFilePath() ?? $error->getFilePath()),
350350
$metadata[InternalError::STACK_TRACE_METADATA_KEY] ?? [],
351351
$metadata[InternalError::STACK_TRACE_AS_STRING_METADATA_KEY] ?? null,
352-
true,
352+
shouldReportBug: true,
353353
);
354354
}
355355

‎src/Command/WorkerCommand.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private function runWorker(
187187
'communicating with main process in parallel worker',
188188
InternalError::prepareTrace($error),
189189
$error->getTraceAsString(),
190-
true,
190+
shouldReportBug: true,
191191
),
192192
],
193193
'filteredPhpErrors' => [],
@@ -262,7 +262,7 @@ private function runWorker(
262262
sprintf('analysing file %s', $file),
263263
InternalError::prepareTrace($t),
264264
$t->getTraceAsString(),
265-
true,
265+
shouldReportBug: true,
266266
);
267267
}
268268
}

0 commit comments

Comments
 (0)