Skip to content

Commit 71b4ffa

Browse files
committed
Filter out implicit throw points from callables when exceptions.implicitThrows: false
1 parent 8863f54 commit 71b4ffa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,11 @@ static function (): void {
22322232
$throwPoints = array_merge($throwPoints, $invokeResult->getThrowPoints());
22332233
$impurePoints = array_merge($impurePoints, $invokeResult->getImpurePoints());
22342234
} elseif ($parametersAcceptor instanceof CallableParametersAcceptor) {
2235-
$throwPoints = array_merge($throwPoints, array_map(static fn (SimpleThrowPoint $throwPoint) => $throwPoint->isExplicit() ? ThrowPoint::createExplicit($scope, $throwPoint->getType(), $expr, $throwPoint->canContainAnyThrowable()) : ThrowPoint::createImplicit($scope, $expr), $parametersAcceptor->getThrowPoints()));
2235+
$callableThrowPoints = array_map(static fn (SimpleThrowPoint $throwPoint) => $throwPoint->isExplicit() ? ThrowPoint::createExplicit($scope, $throwPoint->getType(), $expr, $throwPoint->canContainAnyThrowable()) : ThrowPoint::createImplicit($scope, $expr), $parametersAcceptor->getThrowPoints());
2236+
if (!$this->implicitThrows) {
2237+
$callableThrowPoints = array_values(array_filter($callableThrowPoints, static fn (ThrowPoint $throwPoint) => $throwPoint->isExplicit()));
2238+
}
2239+
$throwPoints = array_merge($throwPoints, $callableThrowPoints);
22362240
$impurePoints = array_merge($impurePoints, array_map(static fn (SimpleImpurePoint $impurePoint) => new ImpurePoint($scope, $expr, $impurePoint->getIdentifier(), $impurePoint->getDescription(), $impurePoint->isCertain()), $parametersAcceptor->getImpurePoints()));
22372241

22382242
$scope = $this->processImmediatelyCalledCallable($scope, $parametersAcceptor->getInvalidateExpressions(), $parametersAcceptor->getUsedVariables());
@@ -4404,7 +4408,11 @@ private function processArgs(
44044408
if (count($acceptors) === 1) {
44054409
$scope = $this->processImmediatelyCalledCallable($scope, $acceptors[0]->getInvalidateExpressions(), $acceptors[0]->getUsedVariables());
44064410
if ($callCallbackImmediately) {
4407-
$throwPoints = array_merge($throwPoints, array_map(static fn (SimpleThrowPoint $throwPoint) => $throwPoint->isExplicit() ? ThrowPoint::createExplicit($scope, $throwPoint->getType(), $arg->value, $throwPoint->canContainAnyThrowable()) : ThrowPoint::createImplicit($scope, $arg->value), $acceptors[0]->getThrowPoints()));
4411+
$callableThrowPoints = array_map(static fn (SimpleThrowPoint $throwPoint) => $throwPoint->isExplicit() ? ThrowPoint::createExplicit($scope, $throwPoint->getType(), $arg->value, $throwPoint->canContainAnyThrowable()) : ThrowPoint::createImplicit($scope, $arg->value), $acceptors[0]->getThrowPoints());
4412+
if (!$this->implicitThrows) {
4413+
$callableThrowPoints = array_values(array_filter($callableThrowPoints, static fn (ThrowPoint $throwPoint) => $throwPoint->isExplicit()));
4414+
}
4415+
$throwPoints = array_merge($throwPoints, $callableThrowPoints);
44084416
$impurePoints = array_merge($impurePoints, array_map(static fn (SimpleImpurePoint $impurePoint) => new ImpurePoint($scope, $arg->value, $impurePoint->getIdentifier(), $impurePoint->getDescription(), $impurePoint->isCertain()), $acceptors[0]->getImpurePoints()));
44094417
}
44104418
}

0 commit comments

Comments
 (0)