Skip to content

Commit

Permalink
final touch: move to private method to reuse validate
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 17, 2022
1 parent 13c4730 commit b8c2b3b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Reflection/ReflectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,7 @@ private function resolveFunctionReflectionFromFuncCall(
if ($funcCall->name instanceof Name) {
if ($this->reflectionProvider->hasFunction($funcCall->name, $scope)) {
$function = $this->reflectionProvider->getFunction($funcCall->name, $scope);
$fileName = (string) $function->getFileName();

// function inside phpstan.phar may conflict with defined function
if (str_contains($fileName, 'phpstan.phar')) {
return null;
}

return $function;
return $this->resolveFunction($function);
}

return null;
Expand All @@ -282,6 +275,20 @@ private function resolveFunctionReflectionFromFuncCall(

// fallback to callable
$funcCallNameType = $scope->getType($funcCall->name);
return $this->typeToCallReflectionResolverRegistry->resolve($funcCallNameType, $scope);
$function = $this->typeToCallReflectionResolverRegistry->resolve($funcCallNameType, $scope);
return $this->resolveFunction($function);
}

private function resolveFunction(
FunctionReflection | MethodReflection $reflection
): FunctionReflection | MethodReflection | null {
$fileName = (string) $reflection->getFileName();

// function inside phpstan.phar may conflict with defined function
if (str_contains($fileName, 'phpstan.phar')) {
return null;
}

return $reflection;
}
}

0 comments on commit b8c2b3b

Please sign in to comment.