mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-03 13:40:00 +09:00
Update composer dependencies
This commit is contained in:
5
vendor/symfony/options-resolver/CHANGELOG.md
vendored
5
vendor/symfony/options-resolver/CHANGELOG.md
vendored
@@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* added `OptionsResolver::addNormalizer` method
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class OptionsResolverIntrospector
|
||||
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option));
|
||||
}
|
||||
|
||||
if (!array_key_exists($option, $this->{$property})) {
|
||||
if (!\array_key_exists($option, $this->{$property})) {
|
||||
throw new NoConfigurationException($message);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,14 @@ class OptionsResolverIntrospector
|
||||
* @throws NoConfigurationException on no configured normalizer
|
||||
*/
|
||||
public function getNormalizer(string $option): \Closure
|
||||
{
|
||||
return current($this->getNormalizers($option));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NoConfigurationException when no normalizer is configured
|
||||
*/
|
||||
public function getNormalizers(string $option): array
|
||||
{
|
||||
return ($this->get)('normalizers', $option, sprintf('No normalizer was set for the "%s" option.', $option));
|
||||
}
|
||||
|
||||
139
vendor/symfony/options-resolver/OptionsResolver.php
vendored
139
vendor/symfony/options-resolver/OptionsResolver.php
vendored
@@ -30,68 +30,68 @@ class OptionsResolver implements Options
|
||||
/**
|
||||
* The names of all defined options.
|
||||
*/
|
||||
private $defined = array();
|
||||
private $defined = [];
|
||||
|
||||
/**
|
||||
* The default option values.
|
||||
*/
|
||||
private $defaults = array();
|
||||
private $defaults = [];
|
||||
|
||||
/**
|
||||
* A list of closure for nested options.
|
||||
*
|
||||
* @var \Closure[][]
|
||||
*/
|
||||
private $nested = array();
|
||||
private $nested = [];
|
||||
|
||||
/**
|
||||
* The names of required options.
|
||||
*/
|
||||
private $required = array();
|
||||
private $required = [];
|
||||
|
||||
/**
|
||||
* The resolved option values.
|
||||
*/
|
||||
private $resolved = array();
|
||||
private $resolved = [];
|
||||
|
||||
/**
|
||||
* A list of normalizer closures.
|
||||
*
|
||||
* @var \Closure[]
|
||||
* @var \Closure[][]
|
||||
*/
|
||||
private $normalizers = array();
|
||||
private $normalizers = [];
|
||||
|
||||
/**
|
||||
* A list of accepted values for each option.
|
||||
*/
|
||||
private $allowedValues = array();
|
||||
private $allowedValues = [];
|
||||
|
||||
/**
|
||||
* A list of accepted types for each option.
|
||||
*/
|
||||
private $allowedTypes = array();
|
||||
private $allowedTypes = [];
|
||||
|
||||
/**
|
||||
* A list of closures for evaluating lazy options.
|
||||
*/
|
||||
private $lazy = array();
|
||||
private $lazy = [];
|
||||
|
||||
/**
|
||||
* A list of lazy options whose closure is currently being called.
|
||||
*
|
||||
* This list helps detecting circular dependencies between lazy options.
|
||||
*/
|
||||
private $calling = array();
|
||||
private $calling = [];
|
||||
|
||||
/**
|
||||
* A list of deprecated options.
|
||||
*/
|
||||
private $deprecated = array();
|
||||
private $deprecated = [];
|
||||
|
||||
/**
|
||||
* The list of options provided by the user.
|
||||
*/
|
||||
private $given = array();
|
||||
private $given = [];
|
||||
|
||||
/**
|
||||
* Whether the instance is locked for reading.
|
||||
@@ -103,11 +103,11 @@ class OptionsResolver implements Options
|
||||
*/
|
||||
private $locked = false;
|
||||
|
||||
private static $typeAliases = array(
|
||||
private static $typeAliases = [
|
||||
'boolean' => 'bool',
|
||||
'integer' => 'int',
|
||||
'double' => 'float',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Sets the default value of a given option.
|
||||
@@ -146,7 +146,7 @@ class OptionsResolver implements Options
|
||||
* following signature:
|
||||
*
|
||||
* $options->setDefault('database', function (OptionsResolver $resolver) {
|
||||
* $resolver->setDefined(array('dbname', 'host', 'port', 'user', 'pass'));
|
||||
* $resolver->setDefined(['dbname', 'host', 'port', 'user', 'pass']);
|
||||
* }
|
||||
*
|
||||
* To get access to the parent options, add a second argument to the closure's
|
||||
@@ -186,7 +186,7 @@ class OptionsResolver implements Options
|
||||
|
||||
// Ignore previous lazy options if the closure has no second parameter
|
||||
if (!isset($this->lazy[$option]) || !isset($params[1])) {
|
||||
$this->lazy[$option] = array();
|
||||
$this->lazy[$option] = [];
|
||||
}
|
||||
|
||||
// Store closure for later evaluation
|
||||
@@ -202,7 +202,7 @@ class OptionsResolver implements Options
|
||||
if (isset($params[0]) && null !== ($class = $params[0]->getClass()) && self::class === $class->name && (!isset($params[1]) || (null !== ($class = $params[1]->getClass()) && Options::class === $class->name))) {
|
||||
// Store closure for later evaluation
|
||||
$this->nested[$option][] = $value;
|
||||
$this->defaults[$option] = array();
|
||||
$this->defaults[$option] = [];
|
||||
$this->defined[$option] = true;
|
||||
|
||||
// Make sure the option is processed and is not lazy anymore
|
||||
@@ -219,7 +219,7 @@ class OptionsResolver implements Options
|
||||
// to resolve options with lazy closures, normalizers or validation
|
||||
// rules, none of which can exist for undefined options
|
||||
// If the option was resolved before, update the resolved value
|
||||
if (!isset($this->defined[$option]) || array_key_exists($option, $this->resolved)) {
|
||||
if (!isset($this->defined[$option]) || \array_key_exists($option, $this->resolved)) {
|
||||
$this->resolved[$option] = $value;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ class OptionsResolver implements Options
|
||||
*/
|
||||
public function hasDefault($option)
|
||||
{
|
||||
return array_key_exists($option, $this->defaults);
|
||||
return \array_key_exists($option, $this->defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +324,7 @@ class OptionsResolver implements Options
|
||||
*/
|
||||
public function isMissing($option)
|
||||
{
|
||||
return isset($this->required[$option]) && !array_key_exists($option, $this->defaults);
|
||||
return isset($this->required[$option]) && !\array_key_exists($option, $this->defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,7 +484,56 @@ class OptionsResolver implements Options
|
||||
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
|
||||
}
|
||||
|
||||
$this->normalizers[$option] = $normalizer;
|
||||
$this->normalizers[$option] = [$normalizer];
|
||||
|
||||
// Make sure the option is processed
|
||||
unset($this->resolved[$option]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a normalizer for an option.
|
||||
*
|
||||
* The normalizer should be a closure with the following signature:
|
||||
*
|
||||
* function (Options $options, $value): mixed {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
* The closure is invoked when {@link resolve()} is called. The closure
|
||||
* has access to the resolved values of other options through the passed
|
||||
* {@link Options} instance.
|
||||
*
|
||||
* The second parameter passed to the closure is the value of
|
||||
* the option.
|
||||
*
|
||||
* The resolved option value is set to the return value of the closure.
|
||||
*
|
||||
* @param string $option The option name
|
||||
* @param \Closure $normalizer The normalizer
|
||||
* @param bool $forcePrepend If set to true, prepend instead of appending
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws UndefinedOptionsException If the option is undefined
|
||||
* @throws AccessException If called from a lazy option or normalizer
|
||||
*/
|
||||
public function addNormalizer(string $option, \Closure $normalizer, bool $forcePrepend = false): self
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new AccessException('Normalizers cannot be set from a lazy option or normalizer.');
|
||||
}
|
||||
|
||||
if (!isset($this->defined[$option])) {
|
||||
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
|
||||
}
|
||||
|
||||
if ($forcePrepend) {
|
||||
array_unshift($this->normalizers[$option], $normalizer);
|
||||
} else {
|
||||
$this->normalizers[$option][] = $normalizer;
|
||||
}
|
||||
|
||||
// Make sure the option is processed
|
||||
unset($this->resolved[$option]);
|
||||
@@ -523,7 +572,7 @@ class OptionsResolver implements Options
|
||||
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
|
||||
}
|
||||
|
||||
$this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : array($allowedValues);
|
||||
$this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : [$allowedValues];
|
||||
|
||||
// Make sure the option is processed
|
||||
unset($this->resolved[$option]);
|
||||
@@ -565,7 +614,7 @@ class OptionsResolver implements Options
|
||||
}
|
||||
|
||||
if (!\is_array($allowedValues)) {
|
||||
$allowedValues = array($allowedValues);
|
||||
$allowedValues = [$allowedValues];
|
||||
}
|
||||
|
||||
if (!isset($this->allowedValues[$option])) {
|
||||
@@ -690,16 +739,16 @@ class OptionsResolver implements Options
|
||||
throw new AccessException('Options cannot be cleared from a lazy option or normalizer.');
|
||||
}
|
||||
|
||||
$this->defined = array();
|
||||
$this->defaults = array();
|
||||
$this->nested = array();
|
||||
$this->required = array();
|
||||
$this->resolved = array();
|
||||
$this->lazy = array();
|
||||
$this->normalizers = array();
|
||||
$this->allowedTypes = array();
|
||||
$this->allowedValues = array();
|
||||
$this->deprecated = array();
|
||||
$this->defined = [];
|
||||
$this->defaults = [];
|
||||
$this->nested = [];
|
||||
$this->required = [];
|
||||
$this->resolved = [];
|
||||
$this->lazy = [];
|
||||
$this->normalizers = [];
|
||||
$this->allowedTypes = [];
|
||||
$this->allowedValues = [];
|
||||
$this->deprecated = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -728,7 +777,7 @@ class OptionsResolver implements Options
|
||||
* @throws NoSuchOptionException If a lazy option reads an unavailable option
|
||||
* @throws AccessException If called from a lazy option or normalizer
|
||||
*/
|
||||
public function resolve(array $options = array())
|
||||
public function resolve(array $options = [])
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new AccessException('Options cannot be resolved from a lazy option or normalizer.');
|
||||
@@ -800,16 +849,16 @@ class OptionsResolver implements Options
|
||||
$triggerDeprecation = 1 === \func_num_args() || \func_get_arg(1);
|
||||
|
||||
// Shortcut for resolved options
|
||||
if (isset($this->resolved[$option]) || array_key_exists($option, $this->resolved)) {
|
||||
if (isset($this->resolved[$option]) || \array_key_exists($option, $this->resolved)) {
|
||||
if ($triggerDeprecation && isset($this->deprecated[$option]) && (isset($this->given[$option]) || $this->calling) && \is_string($this->deprecated[$option])) {
|
||||
@trigger_error(strtr($this->deprecated[$option], array('%name%' => $option)), E_USER_DEPRECATED);
|
||||
@trigger_error(strtr($this->deprecated[$option], ['%name%' => $option]), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return $this->resolved[$option];
|
||||
}
|
||||
|
||||
// Check whether the option is set at all
|
||||
if (!isset($this->defaults[$option]) && !array_key_exists($option, $this->defaults)) {
|
||||
if (!isset($this->defaults[$option]) && !\array_key_exists($option, $this->defaults)) {
|
||||
if (!isset($this->defined[$option])) {
|
||||
throw new NoSuchOptionException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
|
||||
}
|
||||
@@ -869,7 +918,7 @@ class OptionsResolver implements Options
|
||||
// Validate the type of the resolved option
|
||||
if (isset($this->allowedTypes[$option])) {
|
||||
$valid = false;
|
||||
$invalidTypes = array();
|
||||
$invalidTypes = [];
|
||||
|
||||
foreach ($this->allowedTypes[$option] as $type) {
|
||||
$type = self::$typeAliases[$type] ?? $type;
|
||||
@@ -893,7 +942,7 @@ class OptionsResolver implements Options
|
||||
// Validate the value of the resolved option
|
||||
if (isset($this->allowedValues[$option])) {
|
||||
$success = false;
|
||||
$printableAllowedValues = array();
|
||||
$printableAllowedValues = [];
|
||||
|
||||
foreach ($this->allowedValues[$option] as $allowedValue) {
|
||||
if ($allowedValue instanceof \Closure) {
|
||||
@@ -954,7 +1003,7 @@ class OptionsResolver implements Options
|
||||
}
|
||||
|
||||
if ('' !== $deprecationMessage) {
|
||||
@trigger_error(strtr($deprecationMessage, array('%name%' => $option)), E_USER_DEPRECATED);
|
||||
@trigger_error(strtr($deprecationMessage, ['%name%' => $option]), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -966,15 +1015,15 @@ class OptionsResolver implements Options
|
||||
throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
|
||||
}
|
||||
|
||||
$normalizer = $this->normalizers[$option];
|
||||
|
||||
// The following section must be protected from cyclic
|
||||
// calls. Set $calling for the current $option to detect a cyclic
|
||||
// dependency
|
||||
// BEGIN
|
||||
$this->calling[$option] = true;
|
||||
try {
|
||||
$value = $normalizer($this, $value);
|
||||
foreach ($this->normalizers[$option] as $normalizer) {
|
||||
$value = $normalizer($this, $value);
|
||||
}
|
||||
} finally {
|
||||
unset($this->calling[$option]);
|
||||
}
|
||||
@@ -1033,7 +1082,7 @@ class OptionsResolver implements Options
|
||||
throw new AccessException('Array access is only supported within closures of lazy options and normalizers.');
|
||||
}
|
||||
|
||||
return array_key_exists($option, $this->defaults);
|
||||
return \array_key_exists($option, $this->defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,7 @@ class OptionsResolverIntrospectorTest extends TestCase
|
||||
public function testGetLazyClosures()
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
$closures = array();
|
||||
$closures = [];
|
||||
$resolver->setDefault($option = 'foo', $closures[] = function (Options $options) {});
|
||||
|
||||
$debug = new OptionsResolverIntrospector($resolver);
|
||||
@@ -100,7 +100,7 @@ class OptionsResolverIntrospectorTest extends TestCase
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
$resolver->setDefined($option = 'foo');
|
||||
$resolver->setAllowedTypes($option = 'foo', $allowedTypes = array('string', 'bool'));
|
||||
$resolver->setAllowedTypes($option = 'foo', $allowedTypes = ['string', 'bool']);
|
||||
|
||||
$debug = new OptionsResolverIntrospector($resolver);
|
||||
$this->assertSame($allowedTypes, $debug->getAllowedTypes($option));
|
||||
@@ -135,7 +135,7 @@ class OptionsResolverIntrospectorTest extends TestCase
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
$resolver->setDefined($option = 'foo');
|
||||
$resolver->setAllowedValues($option = 'foo', $allowedValues = array('bar', 'baz'));
|
||||
$resolver->setAllowedValues($option = 'foo', $allowedValues = ['bar', 'baz']);
|
||||
|
||||
$debug = new OptionsResolverIntrospector($resolver);
|
||||
$this->assertSame($allowedValues, $debug->getAllowedValues($option));
|
||||
@@ -201,6 +201,42 @@ class OptionsResolverIntrospectorTest extends TestCase
|
||||
$this->assertSame('bar', $debug->getNormalizer('foo'));
|
||||
}
|
||||
|
||||
public function testGetNormalizers()
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
$resolver->setDefined('foo');
|
||||
$resolver->addNormalizer('foo', $normalizer1 = function () {});
|
||||
$resolver->addNormalizer('foo', $normalizer2 = function () {});
|
||||
|
||||
$debug = new OptionsResolverIntrospector($resolver);
|
||||
$this->assertSame([$normalizer1, $normalizer2], $debug->getNormalizers('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
|
||||
* @expectedExceptionMessage No normalizer was set for the "foo" option.
|
||||
*/
|
||||
public function testGetNormalizersThrowsOnNoConfiguredValue()
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
$resolver->setDefined('foo');
|
||||
|
||||
$debug = new OptionsResolverIntrospector($resolver);
|
||||
$debug->getNormalizers('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
|
||||
* @expectedExceptionMessage The option "foo" does not exist.
|
||||
*/
|
||||
public function testGetNormalizersThrowsOnNotDefinedOption()
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
|
||||
$debug = new OptionsResolverIntrospector($resolver);
|
||||
$debug->getNormalizers('foo');
|
||||
}
|
||||
|
||||
public function testGetDeprecationMessage()
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
"dev-master": "4.3-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user