updated-packages
This commit is contained in:
@@ -34,18 +34,18 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
*/
|
||||
private $argumentValueResolvers;
|
||||
|
||||
public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = array())
|
||||
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, $controller): array
|
||||
{
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
|
||||
foreach ($this->argumentMetadataFactory->createArgumentMetadata($controller) as $metadata) {
|
||||
foreach ($this->argumentValueResolvers as $resolver) {
|
||||
@@ -55,12 +55,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_class($resolver)));
|
||||
}
|
||||
|
||||
// continue to the next controller argument
|
||||
@@ -83,12 +85,12 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
|
||||
public static function getDefaultArgumentValueResolvers(): iterable
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new RequestAttributeValueResolver(),
|
||||
new RequestValueResolver(),
|
||||
new SessionValueResolver(),
|
||||
new DefaultValueResolver(),
|
||||
new VariadicValueResolver(),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user