Skip to content

Commit

Permalink
Simplify NodeGetAttributeTypeExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Oct 2, 2024
1 parent edf0856 commit afc2ca4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/ReturnTypeExtension/NodeGetAttributeTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,16 @@ public function getTypeFromMethodCall(
MethodReflection $methodReflection,
MethodCall $methodCall,
Scope $scope
): Type {
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();

): ?Type {
$firstArg = $methodCall->getArgs()[0];

$argumentValue = $this->resolveArgumentValue($firstArg->value);
if ($argumentValue === null) {
return $returnType;
return null;
}

if (! isset(self::ARGUMENT_KEY_TO_RETURN_TYPE[$argumentValue])) {
return $returnType;
return null;
}

$knownReturnType = self::ARGUMENT_KEY_TO_RETURN_TYPE[$argumentValue];
Expand Down

0 comments on commit afc2ca4

Please sign in to comment.