mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 17:30:50 +00:00
bdfd24339f
2e977bd3aa
deploy to original repository
39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Core\PHPStan\Reflection\TypeToCallReflectionResolver;
|
|
|
|
use PHPStan\Analyser\Scope;
|
|
use PHPStan\Reflection\FunctionReflection;
|
|
use PHPStan\Reflection\MethodReflection;
|
|
use PHPStan\Type\Type;
|
|
use Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface;
|
|
final class TypeToCallReflectionResolverRegistry
|
|
{
|
|
/**
|
|
* @var TypeToCallReflectionResolverInterface[]
|
|
* @readonly
|
|
*/
|
|
private $resolvers;
|
|
/**
|
|
* @param TypeToCallReflectionResolverInterface[] $resolvers
|
|
*/
|
|
public function __construct(array $resolvers)
|
|
{
|
|
$this->resolvers = $resolvers;
|
|
}
|
|
/**
|
|
* @return FunctionReflection|MethodReflection|null
|
|
*/
|
|
public function resolve(Type $type, Scope $scope)
|
|
{
|
|
foreach ($this->resolvers as $resolver) {
|
|
if (!$resolver->supports($type)) {
|
|
continue;
|
|
}
|
|
return $resolver->resolve($type, $scope);
|
|
}
|
|
return null;
|
|
}
|
|
}
|