Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Analyser/Analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,19 @@ public function analyse(
}

return new AnalyserResult(
$errors,
$filteredPhpErrors,
$allPhpErrors,
$locallyIgnoredErrors,
$linesToIgnore,
$unmatchedLineIgnores,
[],
$collectedData,
$internalErrorsCount === 0 ? $dependencies : null,
$internalErrorsCount === 0 ? $usedTraitDependencies : null,
$exportedNodes,
$reachedInternalErrorsCountLimit,
memory_get_peak_usage(true),
unorderedErrors: $errors,
filteredPhpErrors: $filteredPhpErrors,
allPhpErrors: $allPhpErrors,
locallyIgnoredErrors: $locallyIgnoredErrors,
linesToIgnore: $linesToIgnore,
unmatchedLineIgnores: $unmatchedLineIgnores,
internalErrors: [],
collectedData: $collectedData,
dependencies: $internalErrorsCount === 0 ? $dependencies : null,
usedTraitDependencies: $internalErrorsCount === 0 ? $usedTraitDependencies : null,
exportedNodes: $exportedNodes,
reachedInternalErrorsCountLimit: $reachedInternalErrorsCountLimit,
peakMemoryUsageBytes: memory_get_peak_usage(true),
);
}

Expand Down
80 changes: 40 additions & 40 deletions src/Analyser/AnalyserResultFinalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function finalize(AnalyserResult $analyserResult, bool $onlyFiles, bool $
sprintf('running CollectedDataNode rule %s', get_class($rule)),
InternalError::prepareTrace($t),
$t->getTraceAsString(),
true,
shouldReportBug: true,
);
continue;
}
Expand Down Expand Up @@ -135,38 +135,38 @@ public function finalize(AnalyserResult $analyserResult, bool $onlyFiles, bool $
}

return $this->addUnmatchedIgnoredErrors(new AnalyserResult(
array_merge($errors, $analyserResult->getFilteredPhpErrors()),
[],
$analyserResult->getAllPhpErrors(),
$locallyIgnoredErrors,
$allLinesToIgnore,
$allUnmatchedLineIgnores,
$internalErrors,
$analyserResult->getCollectedData(),
$analyserResult->getDependencies(),
$analyserResult->getUsedTraitDependencies(),
$analyserResult->getExportedNodes(),
$analyserResult->hasReachedInternalErrorsCountLimit(),
$analyserResult->getPeakMemoryUsageBytes(),
unorderedErrors: array_merge($errors, $analyserResult->getFilteredPhpErrors()),
filteredPhpErrors: [],
allPhpErrors: $analyserResult->getAllPhpErrors(),
locallyIgnoredErrors: $locallyIgnoredErrors,
linesToIgnore: $allLinesToIgnore,
unmatchedLineIgnores: $allUnmatchedLineIgnores,
internalErrors: $internalErrors,
collectedData: $analyserResult->getCollectedData(),
dependencies: $analyserResult->getDependencies(),
usedTraitDependencies: $analyserResult->getUsedTraitDependencies(),
exportedNodes: $analyserResult->getExportedNodes(),
reachedInternalErrorsCountLimit: $analyserResult->hasReachedInternalErrorsCountLimit(),
peakMemoryUsageBytes: $analyserResult->getPeakMemoryUsageBytes(),
), $collectorErrors, $locallyIgnoredCollectorErrors);
}

private function mergeFilteredPhpErrors(AnalyserResult $analyserResult): AnalyserResult
{
return new AnalyserResult(
array_merge($analyserResult->getUnorderedErrors(), $analyserResult->getFilteredPhpErrors()),
[],
$analyserResult->getAllPhpErrors(),
$analyserResult->getLocallyIgnoredErrors(),
$analyserResult->getLinesToIgnore(),
$analyserResult->getUnmatchedLineIgnores(),
$analyserResult->getInternalErrors(),
$analyserResult->getCollectedData(),
$analyserResult->getDependencies(),
$analyserResult->getUsedTraitDependencies(),
$analyserResult->getExportedNodes(),
$analyserResult->hasReachedInternalErrorsCountLimit(),
$analyserResult->getPeakMemoryUsageBytes(),
unorderedErrors: array_merge($analyserResult->getUnorderedErrors(), $analyserResult->getFilteredPhpErrors()),
filteredPhpErrors: [],
allPhpErrors: $analyserResult->getAllPhpErrors(),
locallyIgnoredErrors: $analyserResult->getLocallyIgnoredErrors(),
linesToIgnore: $analyserResult->getLinesToIgnore(),
unmatchedLineIgnores: $analyserResult->getUnmatchedLineIgnores(),
internalErrors: $analyserResult->getInternalErrors(),
collectedData: $analyserResult->getCollectedData(),
dependencies: $analyserResult->getDependencies(),
usedTraitDependencies: $analyserResult->getUsedTraitDependencies(),
exportedNodes: $analyserResult->getExportedNodes(),
reachedInternalErrorsCountLimit: $analyserResult->hasReachedInternalErrorsCountLimit(),
peakMemoryUsageBytes: $analyserResult->getPeakMemoryUsageBytes(),
);
}

Expand Down Expand Up @@ -218,19 +218,19 @@ private function addUnmatchedIgnoredErrors(

return new FinalizerResult(
new AnalyserResult(
$errors,
$analyserResult->getFilteredPhpErrors(),
$analyserResult->getAllPhpErrors(),
$analyserResult->getLocallyIgnoredErrors(),
$analyserResult->getLinesToIgnore(),
$analyserResult->getUnmatchedLineIgnores(),
$analyserResult->getInternalErrors(),
$analyserResult->getCollectedData(),
$analyserResult->getDependencies(),
$analyserResult->getUsedTraitDependencies(),
$analyserResult->getExportedNodes(),
$analyserResult->hasReachedInternalErrorsCountLimit(),
$analyserResult->getPeakMemoryUsageBytes(),
unorderedErrors: $errors,
filteredPhpErrors: $analyserResult->getFilteredPhpErrors(),
allPhpErrors: $analyserResult->getAllPhpErrors(),
locallyIgnoredErrors: $analyserResult->getLocallyIgnoredErrors(),
linesToIgnore: $analyserResult->getLinesToIgnore(),
unmatchedLineIgnores: $analyserResult->getUnmatchedLineIgnores(),
internalErrors: $analyserResult->getInternalErrors(),
collectedData: $analyserResult->getCollectedData(),
dependencies: $analyserResult->getDependencies(),
usedTraitDependencies: $analyserResult->getUsedTraitDependencies(),
exportedNodes: $analyserResult->getExportedNodes(),
reachedInternalErrorsCountLimit: $analyserResult->hasReachedInternalErrorsCountLimit(),
peakMemoryUsageBytes: $analyserResult->getPeakMemoryUsageBytes(),
),
$collectorErrors,
$locallyIgnoredCollectorErrors,
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ConstantResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public function resolveConstantType(string $constantName, Type $constantType): T
$phpdocTypes = $this->dynamicConstantNames[$constantName];
if ($this->container !== null) {
$typeStringResolver = $this->container->getByType(TypeStringResolver::class);
return $typeStringResolver->resolve($phpdocTypes, new NameScope(null, [], null));
return $typeStringResolver->resolve($phpdocTypes, new NameScope(null, [], className: null));
}
return $constantType;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Analyser/ExpressionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ private function __construct(

public static function createTopLevel(): self
{
return new self(false, null, null);
return new self(isDeep: false, inAssignRightSideVariableName: null, inAssignRightSideExpr: null);
}

public static function createDeep(): self
{
return new self(true, null, null);
return new self(isDeep: true, inAssignRightSideVariableName: null, inAssignRightSideExpr: null);
}

public function enterDeep(): self
Expand Down
8 changes: 4 additions & 4 deletions src/Analyser/Ignore/IgnoredErrorHelperResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public function process(
$processIgnoreError = function (Error $error, int $i, $ignore) use (&$unmatchedIgnoredErrors, &$stringErrors): bool {
$shouldBeIgnored = false;
if (is_string($ignore)) {
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, $ignore, null, null, null);
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, ignoredErrorPattern: $ignore, ignoredErrorMessage: null, identifier: null, path: null);
if ($shouldBeIgnored) {
unset($unmatchedIgnoredErrors[$i]);
}
} else {
if (isset($ignore['path'])) {
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, $ignore['message'] ?? null, $ignore['rawMessage'] ?? null, $ignore['identifier'] ?? null, $ignore['path']);
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, ignoredErrorPattern: $ignore['message'] ?? null, ignoredErrorMessage: $ignore['rawMessage'] ?? null, identifier: $ignore['identifier'] ?? null, path: $ignore['path']);
if ($shouldBeIgnored) {
if (isset($ignore['count'])) {
$realCount = $unmatchedIgnoredErrors[$i]['realCount'] ?? 0;
Expand All @@ -85,7 +85,7 @@ public function process(
}
} elseif (isset($ignore['paths'])) {
foreach ($ignore['paths'] as $j => $ignorePath) {
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, $ignore['message'] ?? null, $ignore['rawMessage'] ?? null, $ignore['identifier'] ?? null, $ignorePath);
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, ignoredErrorPattern: $ignore['message'] ?? null, ignoredErrorMessage: $ignore['rawMessage'] ?? null, identifier: $ignore['identifier'] ?? null, path: $ignorePath);
if (!$shouldBeIgnored) {
continue;
}
Expand All @@ -102,7 +102,7 @@ public function process(
break;
}
} else {
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, $ignore['message'] ?? null, $ignore['rawMessage'] ?? null, $ignore['identifier'] ?? null, null);
$shouldBeIgnored = IgnoredError::shouldIgnore($this->fileHelper, $error, ignoredErrorPattern: $ignore['message'] ?? null, ignoredErrorMessage: $ignore['rawMessage'] ?? null, identifier: $ignore['identifier'] ?? null, path: null);
if ($shouldBeIgnored) {
unset($unmatchedIgnoredErrors[$i]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/InternalThrowPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function createExplicit(MutatingScope $scope, Type $type, Node $no
*/
public static function createImplicit(MutatingScope $scope, Node $node): self
{
return new self($scope, new ObjectType(Throwable::class), $node, false, true);
return new self($scope, new ObjectType(Throwable::class), $node, explicit: false, canContainAnyThrowable: true);
}

public static function createFromPublic(ThrowPoint $throwPoint): self
Expand Down
4 changes: 2 additions & 2 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -5611,11 +5611,11 @@ private function getClosureType(Expr\Closure|Expr\ArrowFunction $node): ClosureT
if ($arrayMapArgs !== null) {
$callableParameters = [];
foreach ($arrayMapArgs as $funcCallArg) {
$callableParameters[] = new DummyParameter('item', $this->getType($funcCallArg->value)->getIterableValueType(), false, PassedByReference::createNo(), false, null);
$callableParameters[] = new DummyParameter('item', $this->getType($funcCallArg->value)->getIterableValueType(), optional: false, passedByReference: PassedByReference::createNo(), variadic: false, defaultValue: null);
}
} elseif ($immediatelyInvokedArgs !== null) {
foreach ($immediatelyInvokedArgs as $immediatelyInvokedArg) {
$callableParameters[] = new DummyParameter('item', $this->getType($immediatelyInvokedArg->value), false, PassedByReference::createNo(), false, null);
$callableParameters[] = new DummyParameter('item', $this->getType($immediatelyInvokedArg->value), optional: false, passedByReference: PassedByReference::createNo(), variadic: false, defaultValue: null);
}
} else {
$inFunctionCallsStackCount = count($this->inFunctionCallsStack);
Expand Down
14 changes: 7 additions & 7 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,12 @@ private function processStmtNode(
) {
$methodReflection = $scope->getClassReflection()->getNativeMethod($stmt->name->toString());
if ($methodReflection instanceof NativeMethodReflection) {
return new InternalStatementResult($scope, false, false, [], [], []);
return new InternalStatementResult($scope, hasYield: false, isAlwaysTerminating: false, exitPoints: [], throwPoints: [], impurePoints: []);
}
if ($methodReflection instanceof PhpMethodReflection) {
$declaringTrait = $methodReflection->getDeclaringTrait();
if ($declaringTrait === null || $declaringTrait->getName() !== $scope->getTraitReflection()->getName()) {
return new InternalStatementResult($scope, false, false, [], [], []);
return new InternalStatementResult($scope, hasYield: false, isAlwaysTerminating: false, exitPoints: [], throwPoints: [], impurePoints: []);
}
}
}
Expand Down Expand Up @@ -1013,10 +1013,10 @@ private function processStmtNode(
$throwPoints = [];
$impurePoints = [];
} elseif ($stmt instanceof Node\Stmt\Trait_) {
return new InternalStatementResult($scope, false, false, [], [], []);
return new InternalStatementResult($scope, hasYield: false, isAlwaysTerminating: false, exitPoints: [], throwPoints: [], impurePoints: []);
} elseif ($stmt instanceof Node\Stmt\ClassLike) {
if (!$context->isTopLevel()) {
return new InternalStatementResult($scope, false, false, [], [], []);
return new InternalStatementResult($scope, hasYield: false, isAlwaysTerminating: false, exitPoints: [], throwPoints: [], impurePoints: []);
}
$hasYield = false;
$throwPoints = [];
Expand Down Expand Up @@ -3889,7 +3889,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
}
} elseif ($expr instanceof List_) {
// only in assign and foreach, processed elsewhere
return new ExpressionResult($scope, false, false, [], []);
return new ExpressionResult($scope, hasYield: false, isAlwaysTerminating: false, throwPoints: [], impurePoints: []);
} elseif ($expr instanceof New_) {
$parametersAcceptor = null;
$constructorReflection = null;
Expand Down Expand Up @@ -6445,7 +6445,7 @@ private function processAssignVar(
new GetOffsetValueTypeExpr($assignedExpr, $dimExpr),
$nodeCallback,
$context,
static fn (MutatingScope $scope): ExpressionResult => new ExpressionResult($scope, false, false, [], []),
static fn (MutatingScope $scope): ExpressionResult => new ExpressionResult($scope, hasYield: false, isAlwaysTerminating: false, throwPoints: [], impurePoints: []),
$enterExpressionAssign,
);
$scope = $result->getScope();
Expand Down Expand Up @@ -6553,7 +6553,7 @@ private function processVirtualAssign(MutatingScope $scope, ExpressionResultStor
$assignedExpr,
new VirtualAssignNodeCallback($nodeCallback),
ExpressionContext::createDeep(),
static fn (MutatingScope $scope): ExpressionResult => new ExpressionResult($scope, false, false, [], []),
static fn (MutatingScope $scope): ExpressionResult => new ExpressionResult($scope, hasYield: false, isAlwaysTerminating: false, throwPoints: [], impurePoints: []),
false,
);
}
Expand Down
Loading
Loading