Skip to content

Commit

Permalink
Call getArgs only once
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Nov 1, 2021
1 parent 2e0fe96 commit 228187d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ public function getTypeFromMethodCall(
return $returnType;
}

if (0 === \count($methodCall->getArgs())) {
$args = $methodCall->getArgs();

if (0 === \count($args)) {
return $returnType;
}

$argumentType = $scope->getType($methodCall->getArgs()[0]->value);
$argumentType = $scope->getType($args[0]->value);

if (!$argumentType instanceof Type\Constant\ConstantStringType) {
return $returnType;
Expand Down
5 changes: 3 additions & 2 deletions src/Type/Prophet/ProphesizeDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ public function getTypeFromMethodCall(
$parametersAcceptor = Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());

$returnType = $parametersAcceptor->getReturnType();
$args = $methodCall->getArgs();

if (0 === \count($methodCall->getArgs())) {
if (0 === \count($args)) {
return new Type\Generic\GenericObjectType(
Prophecy\ObjectProphecy::class,
[]
);
}

$argumentType = $scope->getType($methodCall->getArgs()[0]->value);
$argumentType = $scope->getType($args[0]->value);

if (!$argumentType instanceof Type\Constant\ConstantStringType) {
return $returnType;
Expand Down

0 comments on commit 228187d

Please sign in to comment.