Skip to content

Commit 555326e

Browse files
phpstan-botclaude
andcommitted
Inline constructor throw point creation to match MethodCallHandler pattern
Remove createConstructorThrowPoints() method and call getConstructorThrowPoint() directly at the call site, matching how MethodCallHandler uses getMethodThrowPoint(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 06c967a commit 555326e

1 file changed

Lines changed: 8 additions & 19 deletions

File tree

src/Analyser/ExprHandler/NewHandler.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,14 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
206206
$isAlwaysTerminating = $isAlwaysTerminating || $argsResult->isAlwaysTerminating();
207207

208208
if ($deferConstructorThrowPoints) {
209-
$throwPoints = array_merge($throwPoints, $this->createConstructorThrowPoints($expr, $scope, $constructorReflection, $parametersAcceptor, $classReflection, $classFound));
209+
if ($classReflection !== null && $constructorReflection !== null && $parametersAcceptor !== null) {
210+
$constructorThrowPoint = $this->getConstructorThrowPoint($constructorReflection, $parametersAcceptor, $classReflection, $expr, new Name\FullyQualified($classReflection->getName()), $expr->getArgs(), $scope);
211+
if ($constructorThrowPoint !== null) {
212+
$throwPoints[] = $constructorThrowPoint;
213+
}
214+
} elseif (!$classFound) {
215+
$throwPoints[] = InternalThrowPoint::createImplicit($scope, $expr);
216+
}
210217
}
211218

212219
return new ExpressionResult(
@@ -268,24 +275,6 @@ private function processConstructorReflection(string $className, New_ $expr, Mut
268275
return [$constructorReflection, $parametersAcceptor, $classReflection, $classFound, $impurePoints];
269276
}
270277

271-
/**
272-
* @return InternalThrowPoint[]
273-
*/
274-
private function createConstructorThrowPoints(New_ $expr, MutatingScope $scope, ?MethodReflection $constructorReflection, ?ParametersAcceptor $parametersAcceptor, ?ClassReflection $classReflection, bool $classFound): array
275-
{
276-
$throwPoints = [];
277-
if ($classReflection !== null && $constructorReflection !== null && $parametersAcceptor !== null) {
278-
$constructorThrowPoint = $this->getConstructorThrowPoint($constructorReflection, $parametersAcceptor, $classReflection, $expr, new Name\FullyQualified($classReflection->getName()), $expr->getArgs(), $scope);
279-
if ($constructorThrowPoint !== null) {
280-
$throwPoints[] = $constructorThrowPoint;
281-
}
282-
} elseif (!$classFound) {
283-
$throwPoints[] = InternalThrowPoint::createImplicit($scope, $expr);
284-
}
285-
286-
return $throwPoints;
287-
}
288-
289278
/**
290279
* @param list<Node\Arg> $args
291280
*/

0 commit comments

Comments
 (0)