first commit
This commit is contained in:
516
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
vendored
Normal file
516
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,516 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining an array node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface
|
||||
{
|
||||
protected $performDeepMerging = true;
|
||||
protected $ignoreExtraKeys = false;
|
||||
protected $removeExtraKeys = true;
|
||||
protected $children = [];
|
||||
protected $prototype;
|
||||
protected $atLeastOne = false;
|
||||
protected $allowNewKeys = true;
|
||||
protected $key;
|
||||
protected $removeKeyItem;
|
||||
protected $addDefaults = false;
|
||||
protected $addDefaultChildren = false;
|
||||
protected $nodeBuilder;
|
||||
protected $normalizeKeys = true;
|
||||
|
||||
public function __construct(?string $name, ?NodeParentInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->nullEquivalent = [];
|
||||
$this->trueEquivalent = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setBuilder(NodeBuilder $builder)
|
||||
{
|
||||
$this->nodeBuilder = $builder;
|
||||
}
|
||||
|
||||
public function children(): NodeBuilder
|
||||
{
|
||||
return $this->getNodeBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a prototype for child nodes.
|
||||
*/
|
||||
public function prototype(string $type): NodeDefinition
|
||||
{
|
||||
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
|
||||
}
|
||||
|
||||
public function variablePrototype(): VariableNodeDefinition
|
||||
{
|
||||
return $this->prototype('variable');
|
||||
}
|
||||
|
||||
public function scalarPrototype(): ScalarNodeDefinition
|
||||
{
|
||||
return $this->prototype('scalar');
|
||||
}
|
||||
|
||||
public function booleanPrototype(): BooleanNodeDefinition
|
||||
{
|
||||
return $this->prototype('boolean');
|
||||
}
|
||||
|
||||
public function integerPrototype(): IntegerNodeDefinition
|
||||
{
|
||||
return $this->prototype('integer');
|
||||
}
|
||||
|
||||
public function floatPrototype(): FloatNodeDefinition
|
||||
{
|
||||
return $this->prototype('float');
|
||||
}
|
||||
|
||||
public function arrayPrototype(): self
|
||||
{
|
||||
return $this->prototype('array');
|
||||
}
|
||||
|
||||
public function enumPrototype(): EnumNodeDefinition
|
||||
{
|
||||
return $this->prototype('enum');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the default value if the node is not set in the configuration.
|
||||
*
|
||||
* This method is applicable to concrete nodes only (not to prototype nodes).
|
||||
* If this function has been called and the node is not set during the finalization
|
||||
* phase, it's default value will be derived from its children default values.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addDefaultsIfNotSet(): static
|
||||
{
|
||||
$this->addDefaults = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds children with a default value when none are defined.
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @param int|string|array|null $children The number of children|The child name|The children names to be added
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addDefaultChildrenIfNoneSet(int|string|array|null $children = null): static
|
||||
{
|
||||
$this->addDefaultChildren = $children;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires the node to have at least one element.
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function requiresAtLeastOneElement(): static
|
||||
{
|
||||
$this->atLeastOne = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disallows adding news keys in a subsequent configuration.
|
||||
*
|
||||
* If used all keys have to be defined in the same configuration file.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function disallowNewKeysInSubsequentConfigs(): static
|
||||
{
|
||||
$this->allowNewKeys = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a normalization rule for XML configurations.
|
||||
*
|
||||
* @param string $singular The key to remap
|
||||
* @param string|null $plural The plural of the key for irregular plurals
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function fixXmlConfig(string $singular, ?string $plural = null): static
|
||||
{
|
||||
$this->normalization()->remap($singular, $plural);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute which value is to be used as key.
|
||||
*
|
||||
* This is useful when you have an indexed array that should be an
|
||||
* associative array. You can select an item from within the array
|
||||
* to be the key of the particular item. For example, if "id" is the
|
||||
* "key", then:
|
||||
*
|
||||
* [
|
||||
* ['id' => 'my_name', 'foo' => 'bar'],
|
||||
* ];
|
||||
*
|
||||
* becomes
|
||||
*
|
||||
* [
|
||||
* 'my_name' => ['foo' => 'bar'],
|
||||
* ];
|
||||
*
|
||||
* If you'd like "'id' => 'my_name'" to still be present in the resulting
|
||||
* array, then you can set the second argument of this method to false.
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @param string $name The name of the key
|
||||
* @param bool $removeKeyItem Whether or not the key item should be removed
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function useAttributeAsKey(string $name, bool $removeKeyItem = true): static
|
||||
{
|
||||
$this->key = $name;
|
||||
$this->removeKeyItem = $removeKeyItem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be unset.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeUnset(bool $allow = true): static
|
||||
{
|
||||
$this->merge()->allowUnset($allow);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an "enabled" boolean to enable the current section.
|
||||
*
|
||||
* By default, the section is disabled. If any configuration is specified then
|
||||
* the node will be automatically enabled:
|
||||
*
|
||||
* enableableArrayNode: {enabled: true, ...} # The config is enabled & default values get overridden
|
||||
* enableableArrayNode: ~ # The config is enabled & use the default values
|
||||
* enableableArrayNode: true # The config is enabled & use the default values
|
||||
* enableableArrayNode: {other: value, ...} # The config is enabled & default values get overridden
|
||||
* enableableArrayNode: {enabled: false, ...} # The config is disabled
|
||||
* enableableArrayNode: false # The config is disabled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeEnabled(): static
|
||||
{
|
||||
$this
|
||||
->addDefaultsIfNotSet()
|
||||
->treatFalseLike(['enabled' => false])
|
||||
->treatTrueLike(['enabled' => true])
|
||||
->treatNullLike(['enabled' => true])
|
||||
->beforeNormalization()
|
||||
->ifArray()
|
||||
->then(function (array $v) {
|
||||
$v['enabled'] ??= true;
|
||||
|
||||
return $v;
|
||||
})
|
||||
->end()
|
||||
->children()
|
||||
->booleanNode('enabled')
|
||||
->defaultFalse()
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an "enabled" boolean to enable the current section.
|
||||
*
|
||||
* By default, the section is enabled.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeDisabled(): static
|
||||
{
|
||||
$this
|
||||
->addDefaultsIfNotSet()
|
||||
->treatFalseLike(['enabled' => false])
|
||||
->treatTrueLike(['enabled' => true])
|
||||
->treatNullLike(['enabled' => true])
|
||||
->children()
|
||||
->booleanNode('enabled')
|
||||
->defaultTrue()
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the deep merging of the node.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function performNoDeepMerging(): static
|
||||
{
|
||||
$this->performDeepMerging = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows extra config keys to be specified under an array without
|
||||
* throwing an exception.
|
||||
*
|
||||
* Those config values are ignored and removed from the resulting
|
||||
* array. This should be used only in special cases where you want
|
||||
* to send an entire configuration array through a special tree that
|
||||
* processes only part of the array.
|
||||
*
|
||||
* @param bool $remove Whether to remove the extra keys
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ignoreExtraKeys(bool $remove = true): static
|
||||
{
|
||||
$this->ignoreExtraKeys = true;
|
||||
$this->removeExtraKeys = $remove;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to enable key normalization.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function normalizeKeys(bool $bool): static
|
||||
{
|
||||
$this->normalizeKeys = $bool;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function append(NodeDefinition $node): static
|
||||
{
|
||||
$this->children[$node->name] = $node->setParent($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a node builder to be used to add children and prototype.
|
||||
*/
|
||||
protected function getNodeBuilder(): NodeBuilder
|
||||
{
|
||||
$this->nodeBuilder ??= new NodeBuilder();
|
||||
|
||||
return $this->nodeBuilder->setParent($this);
|
||||
}
|
||||
|
||||
protected function createNode(): NodeInterface
|
||||
{
|
||||
if (!isset($this->prototype)) {
|
||||
$node = new ArrayNode($this->name, $this->parent, $this->pathSeparator);
|
||||
|
||||
$this->validateConcreteNode($node);
|
||||
|
||||
$node->setAddIfNotSet($this->addDefaults);
|
||||
|
||||
foreach ($this->children as $child) {
|
||||
$child->parent = $node;
|
||||
$node->addChild($child->getNode());
|
||||
}
|
||||
} else {
|
||||
$node = new PrototypedArrayNode($this->name, $this->parent, $this->pathSeparator);
|
||||
|
||||
$this->validatePrototypeNode($node);
|
||||
|
||||
if (null !== $this->key) {
|
||||
$node->setKeyAttribute($this->key, $this->removeKeyItem);
|
||||
}
|
||||
|
||||
if (true === $this->atLeastOne || false === $this->allowEmptyValue) {
|
||||
$node->setMinNumberOfElements(1);
|
||||
}
|
||||
|
||||
if ($this->default) {
|
||||
if (!\is_array($this->defaultValue)) {
|
||||
throw new \InvalidArgumentException(sprintf('%s: the default value of an array node has to be an array.', $node->getPath()));
|
||||
}
|
||||
|
||||
$node->setDefaultValue($this->defaultValue);
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
$node->setAddChildrenIfNoneSet($this->addDefaultChildren);
|
||||
if ($this->prototype instanceof static && !isset($this->prototype->prototype)) {
|
||||
$this->prototype->addDefaultsIfNotSet();
|
||||
}
|
||||
}
|
||||
|
||||
$this->prototype->parent = $node;
|
||||
$node->setPrototype($this->prototype->getNode());
|
||||
}
|
||||
|
||||
$node->setAllowNewKeys($this->allowNewKeys);
|
||||
$node->addEquivalentValue(null, $this->nullEquivalent);
|
||||
$node->addEquivalentValue(true, $this->trueEquivalent);
|
||||
$node->addEquivalentValue(false, $this->falseEquivalent);
|
||||
$node->setPerformDeepMerging($this->performDeepMerging);
|
||||
$node->setRequired($this->required);
|
||||
$node->setIgnoreExtraKeys($this->ignoreExtraKeys, $this->removeExtraKeys);
|
||||
$node->setNormalizeKeys($this->normalizeKeys);
|
||||
|
||||
if ($this->deprecation) {
|
||||
$node->setDeprecated($this->deprecation['package'], $this->deprecation['version'], $this->deprecation['message']);
|
||||
}
|
||||
|
||||
if (isset($this->normalization)) {
|
||||
$node->setNormalizationClosures($this->normalization->before);
|
||||
$node->setNormalizedTypes($this->normalization->declaredTypes);
|
||||
$node->setXmlRemappings($this->normalization->remappings);
|
||||
}
|
||||
|
||||
if (isset($this->merge)) {
|
||||
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
||||
$node->setAllowFalse($this->merge->allowFalse);
|
||||
}
|
||||
|
||||
if (isset($this->validation)) {
|
||||
$node->setFinalValidationClosures($this->validation->rules);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the configuration of a concrete node.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
protected function validateConcreteNode(ArrayNode $node)
|
||||
{
|
||||
$path = $node->getPath();
|
||||
|
||||
if (null !== $this->key) {
|
||||
throw new InvalidDefinitionException(sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (false === $this->allowEmptyValue) {
|
||||
throw new InvalidDefinitionException(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (true === $this->atLeastOne) {
|
||||
throw new InvalidDefinitionException(sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if ($this->default) {
|
||||
throw new InvalidDefinitionException(sprintf('->defaultValue() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s".', $path));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the configuration of a prototype node.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
protected function validatePrototypeNode(PrototypedArrayNode $node)
|
||||
{
|
||||
$path = $node->getPath();
|
||||
|
||||
if ($this->addDefaults) {
|
||||
throw new InvalidDefinitionException(sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
if ($this->default) {
|
||||
throw new InvalidDefinitionException(sprintf('A default value and default children might not be used together at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (null !== $this->key && (null === $this->addDefaultChildren || \is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
|
||||
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s".', $path));
|
||||
}
|
||||
|
||||
if (null === $this->key && (\is_string($this->addDefaultChildren) || \is_array($this->addDefaultChildren))) {
|
||||
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s".', $path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeDefinition[]
|
||||
*/
|
||||
public function getChildNodeDefinitions(): array
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a node defined by the given $nodePath.
|
||||
*
|
||||
* @param string $nodePath The path of the node to find. e.g "doctrine.orm.mappings"
|
||||
*/
|
||||
public function find(string $nodePath): NodeDefinition
|
||||
{
|
||||
$firstPathSegment = (false === $pathSeparatorPos = strpos($nodePath, $this->pathSeparator))
|
||||
? $nodePath
|
||||
: substr($nodePath, 0, $pathSeparatorPos);
|
||||
|
||||
if (null === $node = ($this->children[$firstPathSegment] ?? null)) {
|
||||
throw new \RuntimeException(sprintf('Node with name "%s" does not exist in the current node "%s".', $firstPathSegment, $this->name));
|
||||
}
|
||||
|
||||
if (false === $pathSeparatorPos) {
|
||||
return $node;
|
||||
}
|
||||
|
||||
return $node->find(substr($nodePath, $pathSeparatorPos + \strlen($this->pathSeparator)));
|
||||
}
|
||||
}
|
46
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php
vendored
Normal file
46
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\BooleanNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class BooleanNodeDefinition extends ScalarNodeDefinition
|
||||
{
|
||||
public function __construct(?string $name, ?NodeParentInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->nullEquivalent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Node.
|
||||
*/
|
||||
protected function instantiateNode(): BooleanNode
|
||||
{
|
||||
return new BooleanNode($this->name, $this->parent, $this->pathSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
public function cannotBeEmpty(): static
|
||||
{
|
||||
throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
|
||||
}
|
||||
}
|
27
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/BuilderAwareInterface.php
vendored
Normal file
27
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/BuilderAwareInterface.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* An interface that can be implemented by nodes which build other nodes.
|
||||
*
|
||||
* @author Roland Franssen <franssen.roland@gmail.com>
|
||||
*/
|
||||
interface BuilderAwareInterface
|
||||
{
|
||||
/**
|
||||
* Sets a custom children builder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setBuilder(NodeBuilder $builder);
|
||||
}
|
52
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/EnumNodeDefinition.php
vendored
Normal file
52
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/EnumNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
|
||||
/**
|
||||
* Enum Node Definition.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class EnumNodeDefinition extends ScalarNodeDefinition
|
||||
{
|
||||
private array $values;
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function values(array $values): static
|
||||
{
|
||||
if (!$values) {
|
||||
throw new \InvalidArgumentException('->values() must be called with at least one value.');
|
||||
}
|
||||
|
||||
$this->values = $values;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Node.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function instantiateNode(): EnumNode
|
||||
{
|
||||
if (!isset($this->values)) {
|
||||
throw new \RuntimeException('You must call ->values() on enum nodes.');
|
||||
}
|
||||
|
||||
return new EnumNode($this->name, $this->parent, $this->values, $this->pathSeparator);
|
||||
}
|
||||
}
|
252
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/ExprBuilder.php
vendored
Normal file
252
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/ExprBuilder.php
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
||||
|
||||
/**
|
||||
* This class builds an if expression.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*/
|
||||
class ExprBuilder
|
||||
{
|
||||
public const TYPE_ANY = 'any';
|
||||
public const TYPE_STRING = 'string';
|
||||
public const TYPE_NULL = 'null';
|
||||
public const TYPE_ARRAY = 'array';
|
||||
|
||||
protected $node;
|
||||
|
||||
public $allowedTypes;
|
||||
public $ifPart;
|
||||
public $thenPart;
|
||||
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the expression as being always used.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function always(?\Closure $then = null): static
|
||||
{
|
||||
$this->ifPart = static fn () => true;
|
||||
$this->allowedTypes = self::TYPE_ANY;
|
||||
|
||||
if (null !== $then) {
|
||||
$this->thenPart = $then;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure to use as tests.
|
||||
*
|
||||
* The default one tests if the value is true.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifTrue(?\Closure $closure = null): static
|
||||
{
|
||||
$this->ifPart = $closure ?? static fn ($v) => true === $v;
|
||||
$this->allowedTypes = self::TYPE_ANY;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is a string.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifString(): static
|
||||
{
|
||||
$this->ifPart = \is_string(...);
|
||||
$this->allowedTypes = self::TYPE_STRING;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is null.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifNull(): static
|
||||
{
|
||||
$this->ifPart = \is_null(...);
|
||||
$this->allowedTypes = self::TYPE_NULL;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is empty.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifEmpty(): static
|
||||
{
|
||||
$this->ifPart = static fn ($v) => empty($v);
|
||||
$this->allowedTypes = self::TYPE_ANY;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is an array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifArray(): static
|
||||
{
|
||||
$this->ifPart = \is_array(...);
|
||||
$this->allowedTypes = self::TYPE_ARRAY;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is in an array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifInArray(array $array): static
|
||||
{
|
||||
$this->ifPart = static fn ($v) => \in_array($v, $array, true);
|
||||
$this->allowedTypes = self::TYPE_ANY;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is not in an array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ifNotInArray(array $array): static
|
||||
{
|
||||
$this->ifPart = static fn ($v) => !\in_array($v, $array, true);
|
||||
$this->allowedTypes = self::TYPE_ANY;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms variables of any type into an array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function castToArray(): static
|
||||
{
|
||||
$this->ifPart = static fn ($v) => !\is_array($v);
|
||||
$this->allowedTypes = self::TYPE_ANY;
|
||||
$this->thenPart = static fn ($v) => [$v];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the closure to run if the test pass.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function then(\Closure $closure): static
|
||||
{
|
||||
$this->thenPart = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure returning an empty array.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function thenEmptyArray(): static
|
||||
{
|
||||
$this->thenPart = static fn () => [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure marking the value as invalid at processing time.
|
||||
*
|
||||
* if you want to add the value of the node in your message just use a %s placeholder.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function thenInvalid(string $message): static
|
||||
{
|
||||
$this->thenPart = static fn ($v) => throw new \InvalidArgumentException(sprintf($message, json_encode($v)));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure unsetting this key of the array at processing time.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws UnsetKeyException
|
||||
*/
|
||||
public function thenUnset(): static
|
||||
{
|
||||
$this->thenPart = static fn () => throw new UnsetKeyException('Unsetting key.');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related node.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function end(): NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
|
||||
{
|
||||
if (null === $this->ifPart) {
|
||||
throw new \RuntimeException('You must specify an if part.');
|
||||
}
|
||||
if (null === $this->thenPart) {
|
||||
throw new \RuntimeException('You must specify a then part.');
|
||||
}
|
||||
|
||||
return $this->node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the expressions.
|
||||
*
|
||||
* @param ExprBuilder[] $expressions An array of ExprBuilder instances to build
|
||||
*/
|
||||
public static function buildExpressions(array $expressions): array
|
||||
{
|
||||
foreach ($expressions as $k => $expr) {
|
||||
if ($expr instanceof self) {
|
||||
$if = $expr->ifPart;
|
||||
$then = $expr->thenPart;
|
||||
$expressions[$k] = static fn ($v) => $if($v) ? $then($v) : $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $expressions;
|
||||
}
|
||||
}
|
30
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/FloatNodeDefinition.php
vendored
Normal file
30
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/FloatNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\FloatNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a float node.
|
||||
*
|
||||
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
class FloatNodeDefinition extends NumericNodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiates a Node.
|
||||
*/
|
||||
protected function instantiateNode(): FloatNode
|
||||
{
|
||||
return new FloatNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator);
|
||||
}
|
||||
}
|
30
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/IntegerNodeDefinition.php
vendored
Normal file
30
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/IntegerNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\IntegerNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining an integer node.
|
||||
*
|
||||
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
class IntegerNodeDefinition extends NumericNodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiates a Node.
|
||||
*/
|
||||
protected function instantiateNode(): IntegerNode
|
||||
{
|
||||
return new IntegerNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator);
|
||||
}
|
||||
}
|
61
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/MergeBuilder.php
vendored
Normal file
61
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/MergeBuilder.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds merge conditions.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class MergeBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $allowFalse = false;
|
||||
public $allowOverwrite = true;
|
||||
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be unset.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function allowUnset(bool $allow = true): static
|
||||
{
|
||||
$this->allowFalse = $allow;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be overwritten.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function denyOverwrite(bool $deny = true): static
|
||||
{
|
||||
$this->allowOverwrite = !$deny;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related node.
|
||||
*/
|
||||
public function end(): NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
|
||||
{
|
||||
return $this->node;
|
||||
}
|
||||
}
|
204
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NodeBuilder.php
vendored
Normal file
204
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NodeBuilder.php
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for building a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class NodeBuilder implements NodeParentInterface
|
||||
{
|
||||
protected $parent;
|
||||
protected $nodeMapping;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->nodeMapping = [
|
||||
'variable' => VariableNodeDefinition::class,
|
||||
'scalar' => ScalarNodeDefinition::class,
|
||||
'boolean' => BooleanNodeDefinition::class,
|
||||
'integer' => IntegerNodeDefinition::class,
|
||||
'float' => FloatNodeDefinition::class,
|
||||
'array' => ArrayNodeDefinition::class,
|
||||
'enum' => EnumNodeDefinition::class,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent node.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent(?ParentNodeDefinitionInterface $parent = null): static
|
||||
{
|
||||
if (1 > \func_num_args()) {
|
||||
trigger_deprecation('symfony/form', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
|
||||
}
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child array node.
|
||||
*/
|
||||
public function arrayNode(string $name): ArrayNodeDefinition
|
||||
{
|
||||
return $this->node($name, 'array');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child scalar node.
|
||||
*/
|
||||
public function scalarNode(string $name): ScalarNodeDefinition
|
||||
{
|
||||
return $this->node($name, 'scalar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child Boolean node.
|
||||
*/
|
||||
public function booleanNode(string $name): BooleanNodeDefinition
|
||||
{
|
||||
return $this->node($name, 'boolean');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child integer node.
|
||||
*/
|
||||
public function integerNode(string $name): IntegerNodeDefinition
|
||||
{
|
||||
return $this->node($name, 'integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child float node.
|
||||
*/
|
||||
public function floatNode(string $name): FloatNodeDefinition
|
||||
{
|
||||
return $this->node($name, 'float');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child EnumNode.
|
||||
*/
|
||||
public function enumNode(string $name): EnumNodeDefinition
|
||||
{
|
||||
return $this->node($name, 'enum');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child variable node.
|
||||
*/
|
||||
public function variableNode(string $name): VariableNodeDefinition
|
||||
{
|
||||
return $this->node($name, 'variable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*
|
||||
* @return NodeDefinition&ParentNodeDefinitionInterface
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child node.
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not registered
|
||||
* @throws \RuntimeException When the node class is not found
|
||||
*/
|
||||
public function node(?string $name, string $type): NodeDefinition
|
||||
{
|
||||
$class = $this->getNodeClass($type);
|
||||
|
||||
$node = new $class($name);
|
||||
|
||||
$this->append($node);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a node definition.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $node = new ArrayNodeDefinition('name')
|
||||
* ->children()
|
||||
* ->scalarNode('foo')->end()
|
||||
* ->scalarNode('baz')->end()
|
||||
* ->append($this->getBarNodeDefinition())
|
||||
* ->end()
|
||||
* ;
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function append(NodeDefinition $node): static
|
||||
{
|
||||
if ($node instanceof BuilderAwareInterface) {
|
||||
$builder = clone $this;
|
||||
$builder->setParent(null);
|
||||
$node->setBuilder($builder);
|
||||
}
|
||||
|
||||
if (null !== $this->parent) {
|
||||
$this->parent->append($node);
|
||||
// Make this builder the node parent to allow for a fluid interface
|
||||
$node->setParent($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or overrides a node Type.
|
||||
*
|
||||
* @param string $type The name of the type
|
||||
* @param string $class The fully qualified name the node definition class
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNodeClass(string $type, string $class): static
|
||||
{
|
||||
$this->nodeMapping[strtolower($type)] = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name of the node definition.
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not registered
|
||||
* @throws \RuntimeException When the node class is not found
|
||||
*/
|
||||
protected function getNodeClass(string $type): string
|
||||
{
|
||||
$type = strtolower($type);
|
||||
|
||||
if (!isset($this->nodeMapping[$type])) {
|
||||
throw new \RuntimeException(sprintf('The node type "%s" is not registered.', $type));
|
||||
}
|
||||
|
||||
$class = $this->nodeMapping[$type];
|
||||
|
||||
if (!class_exists($class)) {
|
||||
throw new \RuntimeException(sprintf('The node class "%s" does not exist.', $class));
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
}
|
336
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NodeDefinition.php
vendored
Normal file
336
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NodeDefinition.php
vendored
Normal file
@@ -0,0 +1,336 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\BaseNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
abstract class NodeDefinition implements NodeParentInterface
|
||||
{
|
||||
protected $name;
|
||||
protected $normalization;
|
||||
protected $validation;
|
||||
protected $defaultValue;
|
||||
protected $default = false;
|
||||
protected $required = false;
|
||||
protected $deprecation = [];
|
||||
protected $merge;
|
||||
protected $allowEmptyValue = true;
|
||||
protected $nullEquivalent;
|
||||
protected $trueEquivalent = true;
|
||||
protected $falseEquivalent = false;
|
||||
protected $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR;
|
||||
protected $parent;
|
||||
protected $attributes = [];
|
||||
|
||||
public function __construct(?string $name, ?NodeParentInterface $parent = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent node.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent(NodeParentInterface $parent): static
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets info message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info): static
|
||||
{
|
||||
return $this->attribute('info', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets example configuration.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function example(string|array $example): static
|
||||
{
|
||||
return $this->attribute('example', $example);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an attribute on the node.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function attribute(string $key, mixed $value): static
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*/
|
||||
public function end(): NodeParentInterface|NodeBuilder|self|ArrayNodeDefinition|VariableNodeDefinition|null
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the node.
|
||||
*/
|
||||
public function getNode(bool $forceRootNode = false): NodeInterface
|
||||
{
|
||||
if ($forceRootNode) {
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
if (isset($this->normalization)) {
|
||||
$allowedTypes = [];
|
||||
foreach ($this->normalization->before as $expr) {
|
||||
$allowedTypes[] = $expr->allowedTypes;
|
||||
}
|
||||
$allowedTypes = array_unique($allowedTypes);
|
||||
$this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
|
||||
$this->normalization->declaredTypes = $allowedTypes;
|
||||
}
|
||||
|
||||
if (isset($this->validation)) {
|
||||
$this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
|
||||
}
|
||||
|
||||
$node = $this->createNode();
|
||||
if ($node instanceof BaseNode) {
|
||||
$node->setAttributes($this->attributes);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultValue(mixed $value): static
|
||||
{
|
||||
$this->default = true;
|
||||
$this->defaultValue = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node as required.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function isRequired(): static
|
||||
{
|
||||
$this->required = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node as deprecated.
|
||||
*
|
||||
* @param string $package The name of the composer package that is triggering the deprecation
|
||||
* @param string $version The version of the package that introduced the deprecation
|
||||
* @param string $message the deprecation message to use
|
||||
*
|
||||
* You can use %node% and %path% placeholders in your message to display,
|
||||
* respectively, the node name and its complete path
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.'): static
|
||||
{
|
||||
$this->deprecation = [
|
||||
'package' => $package,
|
||||
'version' => $version,
|
||||
'message' => $message,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains null.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatNullLike(mixed $value): static
|
||||
{
|
||||
$this->nullEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains true.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatTrueLike(mixed $value): static
|
||||
{
|
||||
$this->trueEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains false.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatFalseLike(mixed $value): static
|
||||
{
|
||||
$this->falseEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets null as the default value.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultNull(): static
|
||||
{
|
||||
return $this->defaultValue(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets true as the default value.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultTrue(): static
|
||||
{
|
||||
return $this->defaultValue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets false as the default value.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultFalse(): static
|
||||
{
|
||||
return $this->defaultValue(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an expression to run before the normalization.
|
||||
*/
|
||||
public function beforeNormalization(): ExprBuilder
|
||||
{
|
||||
return $this->normalization()->before();
|
||||
}
|
||||
|
||||
/**
|
||||
* Denies the node value being empty.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cannotBeEmpty(): static
|
||||
{
|
||||
$this->allowEmptyValue = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an expression to run for the validation.
|
||||
*
|
||||
* The expression receives the value of the node and must return it. It can
|
||||
* modify it.
|
||||
* An exception should be thrown when the node is not valid.
|
||||
*/
|
||||
public function validate(): ExprBuilder
|
||||
{
|
||||
return $this->validation()->rule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be overwritten.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cannotBeOverwritten(bool $deny = true): static
|
||||
{
|
||||
$this->merge()->denyOverwrite($deny);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for validation rules.
|
||||
*/
|
||||
protected function validation(): ValidationBuilder
|
||||
{
|
||||
return $this->validation ??= new ValidationBuilder($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for merging rules.
|
||||
*/
|
||||
protected function merge(): MergeBuilder
|
||||
{
|
||||
return $this->merge ??= new MergeBuilder($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for normalization rules.
|
||||
*/
|
||||
protected function normalization(): NormalizationBuilder
|
||||
{
|
||||
return $this->normalization ??= new NormalizationBuilder($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate and configure the node according to this definition.
|
||||
*
|
||||
* @throws InvalidDefinitionException When the definition is invalid
|
||||
*/
|
||||
abstract protected function createNode(): NodeInterface;
|
||||
|
||||
/**
|
||||
* Set PathSeparator to use.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPathSeparator(string $separator): static
|
||||
{
|
||||
if ($this instanceof ParentNodeDefinitionInterface) {
|
||||
foreach ($this->getChildNodeDefinitions() as $child) {
|
||||
$child->setPathSeparator($separator);
|
||||
}
|
||||
}
|
||||
|
||||
$this->pathSeparator = $separator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
21
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NodeParentInterface.php
vendored
Normal file
21
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NodeParentInterface.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* An interface that must be implemented by all node parents.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*/
|
||||
interface NodeParentInterface
|
||||
{
|
||||
}
|
61
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php
vendored
Normal file
61
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds normalization conditions.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class NormalizationBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $before = [];
|
||||
public $declaredTypes = [];
|
||||
public $remappings = [];
|
||||
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a key to remap to its plural form.
|
||||
*
|
||||
* @param string $key The key to remap
|
||||
* @param string|null $plural The plural of the key in case of irregular plural
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function remap(string $key, ?string $plural = null): static
|
||||
{
|
||||
$this->remappings[] = [$key, null === $plural ? $key.'s' : $plural];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a closure to run before the normalization or an expression builder to build it if null is provided.
|
||||
*
|
||||
* @return ExprBuilder|$this
|
||||
*/
|
||||
public function before(?\Closure $closure = null): ExprBuilder|static
|
||||
{
|
||||
if (null !== $closure) {
|
||||
$this->before[] = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->before[] = new ExprBuilder($this->node);
|
||||
}
|
||||
}
|
67
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php
vendored
Normal file
67
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
|
||||
/**
|
||||
* Abstract class that contains common code of integer and float node definitions.
|
||||
*
|
||||
* @author David Jeanmonod <david.jeanmonod@gmail.com>
|
||||
*/
|
||||
abstract class NumericNodeDefinition extends ScalarNodeDefinition
|
||||
{
|
||||
protected $min;
|
||||
protected $max;
|
||||
|
||||
/**
|
||||
* Ensures that the value is smaller than the given reference.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException when the constraint is inconsistent
|
||||
*/
|
||||
public function max(int|float $max): static
|
||||
{
|
||||
if (isset($this->min) && $this->min > $max) {
|
||||
throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min));
|
||||
}
|
||||
$this->max = $max;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the value is bigger than the given reference.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException when the constraint is inconsistent
|
||||
*/
|
||||
public function min(int|float $min): static
|
||||
{
|
||||
if (isset($this->max) && $this->max < $min) {
|
||||
throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max));
|
||||
}
|
||||
$this->min = $min;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
public function cannotBeEmpty(): static
|
||||
{
|
||||
throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* An interface that must be implemented by nodes which can have children.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*/
|
||||
interface ParentNodeDefinitionInterface extends BuilderAwareInterface
|
||||
{
|
||||
/**
|
||||
* Returns a builder to add children nodes.
|
||||
*/
|
||||
public function children(): NodeBuilder;
|
||||
|
||||
/**
|
||||
* Appends a node definition.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $node = $parentNode
|
||||
* ->children()
|
||||
* ->scalarNode('foo')->end()
|
||||
* ->scalarNode('baz')->end()
|
||||
* ->append($this->getBarNodeDefinition())
|
||||
* ->end()
|
||||
* ;
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function append(NodeDefinition $node): static;
|
||||
|
||||
/**
|
||||
* Gets the child node definitions.
|
||||
*
|
||||
* @return NodeDefinition[]
|
||||
*/
|
||||
public function getChildNodeDefinitions(): array;
|
||||
}
|
30
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/ScalarNodeDefinition.php
vendored
Normal file
30
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/ScalarNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ScalarNodeDefinition extends VariableNodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiate a Node.
|
||||
*/
|
||||
protected function instantiateNode(): ScalarNode
|
||||
{
|
||||
return new ScalarNode($this->name, $this->parent, $this->pathSeparator);
|
||||
}
|
||||
}
|
67
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/TreeBuilder.php
vendored
Normal file
67
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/TreeBuilder.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
|
||||
/**
|
||||
* This is the entry class for building a config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class TreeBuilder implements NodeParentInterface
|
||||
{
|
||||
/**
|
||||
* @var NodeInterface|null
|
||||
*/
|
||||
protected $tree;
|
||||
|
||||
/**
|
||||
* @var NodeDefinition
|
||||
*/
|
||||
protected $root;
|
||||
|
||||
public function __construct(string $name, string $type = 'array', ?NodeBuilder $builder = null)
|
||||
{
|
||||
$builder ??= new NodeBuilder();
|
||||
$this->root = $builder->node($name, $type)->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeDefinition|ArrayNodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
|
||||
*/
|
||||
public function getRootNode(): NodeDefinition|ArrayNodeDefinition
|
||||
{
|
||||
return $this->root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the tree.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function buildTree(): NodeInterface
|
||||
{
|
||||
return $this->tree ??= $this->root->getNode(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setPathSeparator(string $separator)
|
||||
{
|
||||
// unset last built as changing path separator changes all nodes
|
||||
$this->tree = null;
|
||||
|
||||
$this->root->setPathSeparator($separator);
|
||||
}
|
||||
}
|
44
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/ValidationBuilder.php
vendored
Normal file
44
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/ValidationBuilder.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds validation conditions.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*/
|
||||
class ValidationBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $rules = [];
|
||||
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a closure to run as normalization or an expression builder to build it if null is provided.
|
||||
*
|
||||
* @return ExprBuilder|$this
|
||||
*/
|
||||
public function rule(?\Closure $closure = null): ExprBuilder|static
|
||||
{
|
||||
if (null !== $closure) {
|
||||
$this->rules[] = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->rules[] = new ExprBuilder($this->node);
|
||||
}
|
||||
}
|
64
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/VariableNodeDefinition.php
vendored
Normal file
64
plugins/simplesaml/lib/vendor/symfony/config/Definition/Builder/VariableNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Definition\VariableNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class VariableNodeDefinition extends NodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiate a Node.
|
||||
*/
|
||||
protected function instantiateNode(): VariableNode
|
||||
{
|
||||
return new VariableNode($this->name, $this->parent, $this->pathSeparator);
|
||||
}
|
||||
|
||||
protected function createNode(): NodeInterface
|
||||
{
|
||||
$node = $this->instantiateNode();
|
||||
|
||||
if (isset($this->normalization)) {
|
||||
$node->setNormalizationClosures($this->normalization->before);
|
||||
}
|
||||
|
||||
if (isset($this->merge)) {
|
||||
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
||||
}
|
||||
|
||||
if (true === $this->default) {
|
||||
$node->setDefaultValue($this->defaultValue);
|
||||
}
|
||||
|
||||
$node->setAllowEmptyValue($this->allowEmptyValue);
|
||||
$node->addEquivalentValue(null, $this->nullEquivalent);
|
||||
$node->addEquivalentValue(true, $this->trueEquivalent);
|
||||
$node->addEquivalentValue(false, $this->falseEquivalent);
|
||||
$node->setRequired($this->required);
|
||||
|
||||
if ($this->deprecation) {
|
||||
$node->setDeprecated($this->deprecation['package'], $this->deprecation['version'], $this->deprecation['message']);
|
||||
}
|
||||
|
||||
if (isset($this->validation)) {
|
||||
$node->setFinalValidationClosures($this->validation->rules);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user