Skip to content

Commit 5930232

Browse files
claudeondrejmirtes
authored andcommitted
Use named arguments for unreadable calls
1 parent 349b1ad commit 5930232

32 files changed

+417
-207
lines changed

src/Analyser/Analyser.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,19 @@ public function analyse(
130130
}
131131

132132
return new AnalyserResult(
133-
$errors,
134-
$filteredPhpErrors,
135-
$allPhpErrors,
136-
$locallyIgnoredErrors,
137-
$linesToIgnore,
138-
$unmatchedLineIgnores,
139-
[],
140-
$collectedData,
141-
$internalErrorsCount === 0 ? $dependencies : null,
142-
$internalErrorsCount === 0 ? $usedTraitDependencies : null,
143-
$exportedNodes,
144-
$reachedInternalErrorsCountLimit,
145-
memory_get_peak_usage(true),
133+
unorderedErrors: $errors,
134+
filteredPhpErrors: $filteredPhpErrors,
135+
allPhpErrors: $allPhpErrors,
136+
locallyIgnoredErrors: $locallyIgnoredErrors,
137+
linesToIgnore: $linesToIgnore,
138+
unmatchedLineIgnores: $unmatchedLineIgnores,
139+
internalErrors: [],
140+
collectedData: $collectedData,
141+
dependencies: $internalErrorsCount === 0 ? $dependencies : null,
142+
usedTraitDependencies: $internalErrorsCount === 0 ? $usedTraitDependencies : null,
143+
exportedNodes: $exportedNodes,
144+
reachedInternalErrorsCountLimit: $reachedInternalErrorsCountLimit,
145+
peakMemoryUsageBytes: memory_get_peak_usage(true),
146146
);
147147
}
148148

src/Analyser/AnalyserResultFinalizer.php

Lines changed: 40 additions & 40 deletions
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
}
@@ -135,38 +135,38 @@ public function finalize(AnalyserResult $analyserResult, bool $onlyFiles, bool $
135135
}
136136

137137
return $this->addUnmatchedIgnoredErrors(new AnalyserResult(
138-
array_merge($errors, $analyserResult->getFilteredPhpErrors()),
139-
[],
140-
$analyserResult->getAllPhpErrors(),
141-
$locallyIgnoredErrors,
142-
$allLinesToIgnore,
143-
$allUnmatchedLineIgnores,
144-
$internalErrors,
145-
$analyserResult->getCollectedData(),
146-
$analyserResult->getDependencies(),
147-
$analyserResult->getUsedTraitDependencies(),
148-
$analyserResult->getExportedNodes(),
149-
$analyserResult->hasReachedInternalErrorsCountLimit(),
150-
$analyserResult->getPeakMemoryUsageBytes(),
138+
unorderedErrors: array_merge($errors, $analyserResult->getFilteredPhpErrors()),
139+
filteredPhpErrors: [],
140+
allPhpErrors: $analyserResult->getAllPhpErrors(),
141+
locallyIgnoredErrors: $locallyIgnoredErrors,
142+
linesToIgnore: $allLinesToIgnore,
143+
unmatchedLineIgnores: $allUnmatchedLineIgnores,
144+
internalErrors: $internalErrors,
145+
collectedData: $analyserResult->getCollectedData(),
146+
dependencies: $analyserResult->getDependencies(),
147+
usedTraitDependencies: $analyserResult->getUsedTraitDependencies(),
148+
exportedNodes: $analyserResult->getExportedNodes(),
149+
reachedInternalErrorsCountLimit: $analyserResult->hasReachedInternalErrorsCountLimit(),
150+
peakMemoryUsageBytes: $analyserResult->getPeakMemoryUsageBytes(),
151151
), $collectorErrors, $locallyIgnoredCollectorErrors);
152152
}
153153

154154
private function mergeFilteredPhpErrors(AnalyserResult $analyserResult): AnalyserResult
155155
{
156156
return new AnalyserResult(
157-
array_merge($analyserResult->getUnorderedErrors(), $analyserResult->getFilteredPhpErrors()),
158-
[],
159-
$analyserResult->getAllPhpErrors(),
160-
$analyserResult->getLocallyIgnoredErrors(),
161-
$analyserResult->getLinesToIgnore(),
162-
$analyserResult->getUnmatchedLineIgnores(),
163-
$analyserResult->getInternalErrors(),
164-
$analyserResult->getCollectedData(),
165-
$analyserResult->getDependencies(),
166-
$analyserResult->getUsedTraitDependencies(),
167-
$analyserResult->getExportedNodes(),
168-
$analyserResult->hasReachedInternalErrorsCountLimit(),
169-
$analyserResult->getPeakMemoryUsageBytes(),
157+
unorderedErrors: array_merge($analyserResult->getUnorderedErrors(), $analyserResult->getFilteredPhpErrors()),
158+
filteredPhpErrors: [],
159+
allPhpErrors: $analyserResult->getAllPhpErrors(),
160+
locallyIgnoredErrors: $analyserResult->getLocallyIgnoredErrors(),
161+
linesToIgnore: $analyserResult->getLinesToIgnore(),
162+
unmatchedLineIgnores: $analyserResult->getUnmatchedLineIgnores(),
163+
internalErrors: $analyserResult->getInternalErrors(),
164+
collectedData: $analyserResult->getCollectedData(),
165+
dependencies: $analyserResult->getDependencies(),
166+
usedTraitDependencies: $analyserResult->getUsedTraitDependencies(),
167+
exportedNodes: $analyserResult->getExportedNodes(),
168+
reachedInternalErrorsCountLimit: $analyserResult->hasReachedInternalErrorsCountLimit(),
169+
peakMemoryUsageBytes: $analyserResult->getPeakMemoryUsageBytes(),
170170
);
171171
}
172172

@@ -218,19 +218,19 @@ private function addUnmatchedIgnoredErrors(
218218

219219
return new FinalizerResult(
220220
new AnalyserResult(
221-
$errors,
222-
$analyserResult->getFilteredPhpErrors(),
223-
$analyserResult->getAllPhpErrors(),
224-
$analyserResult->getLocallyIgnoredErrors(),
225-
$analyserResult->getLinesToIgnore(),
226-
$analyserResult->getUnmatchedLineIgnores(),
227-
$analyserResult->getInternalErrors(),
228-
$analyserResult->getCollectedData(),
229-
$analyserResult->getDependencies(),
230-
$analyserResult->getUsedTraitDependencies(),
231-
$analyserResult->getExportedNodes(),
232-
$analyserResult->hasReachedInternalErrorsCountLimit(),
233-
$analyserResult->getPeakMemoryUsageBytes(),
221+
unorderedErrors: $errors,
222+
filteredPhpErrors: $analyserResult->getFilteredPhpErrors(),
223+
allPhpErrors: $analyserResult->getAllPhpErrors(),
224+
locallyIgnoredErrors: $analyserResult->getLocallyIgnoredErrors(),
225+
linesToIgnore: $analyserResult->getLinesToIgnore(),
226+
unmatchedLineIgnores: $analyserResult->getUnmatchedLineIgnores(),
227+
internalErrors: $analyserResult->getInternalErrors(),
228+
collectedData: $analyserResult->getCollectedData(),
229+
dependencies: $analyserResult->getDependencies(),
230+
usedTraitDependencies: $analyserResult->getUsedTraitDependencies(),
231+
exportedNodes: $analyserResult->getExportedNodes(),
232+
reachedInternalErrorsCountLimit: $analyserResult->hasReachedInternalErrorsCountLimit(),
233+
peakMemoryUsageBytes: $analyserResult->getPeakMemoryUsageBytes(),
234234
),
235235
$collectorErrors,
236236
$locallyIgnoredCollectorErrors,

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/Ignore/IgnoredErrorHelperResult.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ public function process(
5858
$processIgnoreError = function (Error $error, int $i, $ignore) use (&$unmatchedIgnoredErrors, &$stringErrors): bool {
5959
$shouldBeIgnored = false;
6060
if (is_string($ignore)) {
61-
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, $ignore, null, null, null);
61+
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, ignoredErrorPattern: $ignore, ignoredErrorMessage: null, identifier: null, path: null);
6262
if ($shouldBeIgnored) {
6363
unset($unmatchedIgnoredErrors[$i]);
6464
}
6565
} else {
6666
if (isset($ignore['path'])) {
67-
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, $ignore['message'] ?? null, $ignore['rawMessage'] ?? null, $ignore['identifier'] ?? null, $ignore['path']);
67+
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, ignoredErrorPattern: $ignore['message'] ?? null, ignoredErrorMessage: $ignore['rawMessage'] ?? null, identifier: $ignore['identifier'] ?? null, path: $ignore['path']);
6868
if ($shouldBeIgnored) {
6969
if (isset($ignore['count'])) {
7070
$realCount = $unmatchedIgnoredErrors[$i]['realCount'] ?? 0;
@@ -85,7 +85,7 @@ public function process(
8585
}
8686
} elseif (isset($ignore['paths'])) {
8787
foreach ($ignore['paths'] as $j => $ignorePath) {
88-
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, $ignore['message'] ?? null, $ignore['rawMessage'] ?? null, $ignore['identifier'] ?? null, $ignorePath);
88+
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, ignoredErrorPattern: $ignore['message'] ?? null, ignoredErrorMessage: $ignore['rawMessage'] ?? null, identifier: $ignore['identifier'] ?? null, path: $ignorePath);
8989
if (!$shouldBeIgnored) {
9090
continue;
9191
}
@@ -102,7 +102,7 @@ public function process(
102102
break;
103103
}
104104
} else {
105-
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, $ignore['message'] ?? null, $ignore['rawMessage'] ?? null, $ignore['identifier'] ?? null, null);
105+
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, ignoredErrorPattern: $ignore['message'] ?? null, ignoredErrorMessage: $ignore['rawMessage'] ?? null, identifier: $ignore['identifier'] ?? null, path: null);
106106
if ($shouldBeIgnored) {
107107
unset($unmatchedIgnoredErrors[$i]);
108108
}

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/MutatingScope.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5611,11 +5611,11 @@ private function getClosureType(Expr\Closure|Expr\ArrowFunction $node): ClosureT
56115611
if ($arrayMapArgs !== null) {
56125612
$callableParameters = [];
56135613
foreach ($arrayMapArgs as $funcCallArg) {
5614-
$callableParameters[] = new DummyParameter('item', $this->getType($funcCallArg->value)->getIterableValueType(), false, PassedByReference::createNo(), false, null);
5614+
$callableParameters[] = new DummyParameter('item', $this->getType($funcCallArg->value)->getIterableValueType(), optional: false, passedByReference: PassedByReference::createNo(), variadic: false, defaultValue: null);
56155615
}
56165616
} elseif ($immediatelyInvokedArgs !== null) {
56175617
foreach ($immediatelyInvokedArgs as $immediatelyInvokedArg) {
5618-
$callableParameters[] = new DummyParameter('item', $this->getType($immediatelyInvokedArg->value), false, PassedByReference::createNo(), false, null);
5618+
$callableParameters[] = new DummyParameter('item', $this->getType($immediatelyInvokedArg->value), optional: false, passedByReference: PassedByReference::createNo(), variadic: false, defaultValue: null);
56195619
}
56205620
} else {
56215621
$inFunctionCallsStackCount = count($this->inFunctionCallsStack);

src/Analyser/NodeScopeResolver.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,12 @@ private function processStmtNode(
569569
) {
570570
$methodReflection = $scope->getClassReflection()->getNativeMethod($stmt->name->toString());
571571
if ($methodReflection instanceof NativeMethodReflection) {
572-
return new InternalStatementResult($scope, false, false, [], [], []);
572+
return new InternalStatementResult($scope, hasYield: false, isAlwaysTerminating: false, exitPoints: [], throwPoints: [], impurePoints: []);
573573
}
574574
if ($methodReflection instanceof PhpMethodReflection) {
575575
$declaringTrait = $methodReflection->getDeclaringTrait();
576576
if ($declaringTrait === null || $declaringTrait->getName() !== $scope->getTraitReflection()->getName()) {
577-
return new InternalStatementResult($scope, false, false, [], [], []);
577+
return new InternalStatementResult($scope, hasYield: false, isAlwaysTerminating: false, exitPoints: [], throwPoints: [], impurePoints: []);
578578
}
579579
}
580580
}
@@ -1013,10 +1013,10 @@ private function processStmtNode(
10131013
$throwPoints = [];
10141014
$impurePoints = [];
10151015
} elseif ($stmt instanceof Node\Stmt\Trait_) {
1016-
return new InternalStatementResult($scope, false, false, [], [], []);
1016+
return new InternalStatementResult($scope, hasYield: false, isAlwaysTerminating: false, exitPoints: [], throwPoints: [], impurePoints: []);
10171017
} elseif ($stmt instanceof Node\Stmt\ClassLike) {
10181018
if (!$context->isTopLevel()) {
1019-
return new InternalStatementResult($scope, false, false, [], [], []);
1019+
return new InternalStatementResult($scope, hasYield: false, isAlwaysTerminating: false, exitPoints: [], throwPoints: [], impurePoints: []);
10201020
}
10211021
$hasYield = false;
10221022
$throwPoints = [];
@@ -3889,7 +3889,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
38893889
}
38903890
} elseif ($expr instanceof List_) {
38913891
// only in assign and foreach, processed elsewhere
3892-
return new ExpressionResult($scope, false, false, [], []);
3892+
return new ExpressionResult($scope, hasYield: false, isAlwaysTerminating: false, throwPoints: [], impurePoints: []);
38933893
} elseif ($expr instanceof New_) {
38943894
$parametersAcceptor = null;
38953895
$constructorReflection = null;
@@ -6445,7 +6445,7 @@ private function processAssignVar(
64456445
new GetOffsetValueTypeExpr($assignedExpr, $dimExpr),
64466446
$nodeCallback,
64476447
$context,
6448-
static fn (MutatingScope $scope): ExpressionResult => new ExpressionResult($scope, false, false, [], []),
6448+
static fn (MutatingScope $scope): ExpressionResult => new ExpressionResult($scope, hasYield: false, isAlwaysTerminating: false, throwPoints: [], impurePoints: []),
64496449
$enterExpressionAssign,
64506450
);
64516451
$scope = $result->getScope();
@@ -6553,7 +6553,7 @@ private function processVirtualAssign(MutatingScope $scope, ExpressionResultStor
65536553
$assignedExpr,
65546554
new VirtualAssignNodeCallback($nodeCallback),
65556555
ExpressionContext::createDeep(),
6556-
static fn (MutatingScope $scope): ExpressionResult => new ExpressionResult($scope, false, false, [], []),
6556+
static fn (MutatingScope $scope): ExpressionResult => new ExpressionResult($scope, hasYield: false, isAlwaysTerminating: false, throwPoints: [], impurePoints: []),
65576557
false,
65586558
);
65596559
}

0 commit comments

Comments
 (0)