mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-03 21:49:56 +09:00
Update to laravel 7
This commit is contained in:
@@ -28,22 +28,21 @@ use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactoryInter
|
||||
final class ArgumentResolver implements ArgumentResolverInterface
|
||||
{
|
||||
private $argumentMetadataFactory;
|
||||
|
||||
/**
|
||||
* @var iterable|ArgumentValueResolverInterface[]
|
||||
*/
|
||||
private $argumentValueResolvers;
|
||||
|
||||
/**
|
||||
* @param iterable<mixed, ArgumentValueResolverInterface> $argumentValueResolvers
|
||||
*/
|
||||
public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = [])
|
||||
{
|
||||
$this->argumentMetadataFactory = $argumentMetadataFactory ?: new ArgumentMetadataFactory();
|
||||
$this->argumentMetadataFactory = $argumentMetadataFactory ?? new ArgumentMetadataFactory();
|
||||
$this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getArguments(Request $request, $controller)
|
||||
public function getArguments(Request $request, callable $controller): array
|
||||
{
|
||||
$arguments = [];
|
||||
|
||||
@@ -55,12 +54,14 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
|
||||
$resolved = $resolver->resolve($request, $metadata);
|
||||
|
||||
if (!$resolved instanceof \Generator) {
|
||||
throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', \get_class($resolver)));
|
||||
$atLeastOne = false;
|
||||
foreach ($resolved as $append) {
|
||||
$atLeastOne = true;
|
||||
$arguments[] = $append;
|
||||
}
|
||||
|
||||
foreach ($resolved as $append) {
|
||||
$arguments[] = $append;
|
||||
if (!$atLeastOne) {
|
||||
throw new \InvalidArgumentException(sprintf('"%s::resolve()" must yield at least one value.', get_debug_type($resolver)));
|
||||
}
|
||||
|
||||
// continue to the next controller argument
|
||||
@@ -81,6 +82,9 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable<int, ArgumentValueResolverInterface>
|
||||
*/
|
||||
public static function getDefaultArgumentValueResolvers(): iterable
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user