Skip to content

Commit 2b5c2e6

Browse files
committed
Get rid of getters in InternalThrowPoint
1 parent c8eed73 commit 2b5c2e6

File tree

3 files changed

+9
-37
lines changed

3 files changed

+9
-37
lines changed

src/Analyser/Generator/ExprHandler/ClosureHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function createClosureType(
111111
);
112112
}
113113

114-
$throwPointsForClosureType = array_map(static fn (InternalThrowPoint $throwPoint) => $throwPoint->isExplicit() ? SimpleThrowPoint::createExplicit($throwPoint->getType(), $throwPoint->canContainAnyThrowable()) : SimpleThrowPoint::createImplicit(), $throwPoints);
114+
$throwPointsForClosureType = array_map(static fn (InternalThrowPoint $throwPoint) => $throwPoint->explicit ? SimpleThrowPoint::createExplicit($throwPoint->type, $throwPoint->canContainAnyThrowable) : SimpleThrowPoint::createImplicit(), $throwPoints);
115115
$impurePointsForClosureType = array_map(static fn (ImpurePoint $impurePoint) => new SimpleImpurePoint($impurePoint->getIdentifier(), $impurePoint->getDescription(), $impurePoint->isCertain()), $impurePoints);
116116

117117
$mustUseReturnValue = TrinaryLogic::createNo();

src/Analyser/Generator/InternalThrowPoint.php

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ final class InternalThrowPoint
1717
* @param Node\Expr|Node\Stmt $node
1818
*/
1919
private function __construct(
20-
private GeneratorScope $scope,
21-
private Type $type,
22-
private Node $node,
23-
private bool $explicit,
24-
private bool $canContainAnyThrowable,
20+
public readonly GeneratorScope $scope,
21+
public readonly Type $type,
22+
public readonly Node $node,
23+
public readonly bool $explicit,
24+
public readonly bool $canContainAnyThrowable,
2525
)
2626
{
2727
}
@@ -61,34 +61,6 @@ public static function createFromPublic(ThrowPoint $throwPoint): self
6161
return new self($scope, $throwPoint->getType(), $throwPoint->getNode(), $throwPoint->isExplicit(), $throwPoint->canContainAnyThrowable());
6262
}
6363

64-
public function getScope(): GeneratorScope
65-
{
66-
return $this->scope;
67-
}
68-
69-
public function getType(): Type
70-
{
71-
return $this->type;
72-
}
73-
74-
/**
75-
* @return Node\Expr|Node\Stmt
76-
*/
77-
public function getNode()
78-
{
79-
return $this->node;
80-
}
81-
82-
public function isExplicit(): bool
83-
{
84-
return $this->explicit;
85-
}
86-
87-
public function canContainAnyThrowable(): bool
88-
{
89-
return $this->canContainAnyThrowable;
90-
}
91-
9264
public function subtractCatchType(Type $catchType): self
9365
{
9466
return new self($this->scope, TypeCombinator::remove($this->type, $catchType), $this->node, $this->explicit, $this->canContainAnyThrowable);

src/Analyser/Generator/NodeHandler/ArgsHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function processArgs(
217217
yield from $closureResultGen;
218218
[$closureResult] = $closureResultGen->getReturn();
219219
if ($callCallbackImmediately) {
220-
$throwPoints = array_merge($throwPoints, array_map(static fn (InternalThrowPoint $throwPoint) => $throwPoint->isExplicit() ? InternalThrowPoint::createExplicit($scope, $throwPoint->getType(), $arg->value, $throwPoint->canContainAnyThrowable()) : InternalThrowPoint::createImplicit($scope, $arg->value), $closureResult->throwPoints));
220+
$throwPoints = array_merge($throwPoints, array_map(static fn (InternalThrowPoint $throwPoint) => $throwPoint->explicit ? InternalThrowPoint::createExplicit($scope, $throwPoint->type, $arg->value, $throwPoint->canContainAnyThrowable) : InternalThrowPoint::createImplicit($scope, $arg->value), $closureResult->throwPoints));
221221
$impurePoints = array_merge($impurePoints, $closureResult->impurePoints);
222222
$isAlwaysTerminating = $isAlwaysTerminating || $closureResult->isAlwaysTerminating;
223223
}
@@ -285,7 +285,7 @@ public function processArgs(
285285
yield from $arrowFunctionResultGen;
286286
$arrowFunctionResult = $arrowFunctionResultGen->getReturn();
287287
if ($callCallbackImmediately) {
288-
$throwPoints = array_merge($throwPoints, array_map(static fn (InternalThrowPoint $throwPoint) => $throwPoint->isExplicit() ? InternalThrowPoint::createExplicit($scope, $throwPoint->getType(), $arg->value, $throwPoint->canContainAnyThrowable()) : InternalThrowPoint::createImplicit($scope, $arg->value), $arrowFunctionResult->throwPoints));
288+
$throwPoints = array_merge($throwPoints, array_map(static fn (InternalThrowPoint $throwPoint) => $throwPoint->explicit ? InternalThrowPoint::createExplicit($scope, $throwPoint->type, $arg->value, $throwPoint->canContainAnyThrowable) : InternalThrowPoint::createImplicit($scope, $arg->value), $arrowFunctionResult->throwPoints));
289289
$impurePoints = array_merge($impurePoints, $arrowFunctionResult->impurePoints);
290290
$isAlwaysTerminating = $isAlwaysTerminating || $arrowFunctionResult->isAlwaysTerminating;
291291
}
@@ -305,7 +305,7 @@ public function processArgs(
305305
if ($callCallbackImmediately) {
306306
$callableThrowPoints = array_map(static fn (SimpleThrowPoint $throwPoint) => $throwPoint->isExplicit() ? InternalThrowPoint::createExplicit($scope, $throwPoint->getType(), $arg->value, $throwPoint->canContainAnyThrowable()) : InternalThrowPoint::createImplicit($scope, $arg->value), $acceptors[0]->getThrowPoints());
307307
if (!$this->implicitThrows) {
308-
$callableThrowPoints = array_values(array_filter($callableThrowPoints, static fn (InternalThrowPoint $throwPoint) => $throwPoint->isExplicit()));
308+
$callableThrowPoints = array_values(array_filter($callableThrowPoints, static fn (InternalThrowPoint $throwPoint) => $throwPoint->explicit));
309309
}
310310
$throwPoints = array_merge($throwPoints, $callableThrowPoints);
311311
$impurePoints = array_merge($impurePoints, array_map(static fn (SimpleImpurePoint $impurePoint) => new ImpurePoint($scope, $arg->value, $impurePoint->getIdentifier(), $impurePoint->getDescription(), $impurePoint->isCertain()), $acceptors[0]->getImpurePoints()));

0 commit comments

Comments
 (0)