X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FDefinition%2FBuilder%2FArrayNodeDefinition.php;h=28a00be09110024879f62ce449c418bfcae60e4d;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=a1fc1fab0ef78fbd866f2ad2f00a942c805f740b;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php b/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php index a1fc1fab0..28a00be09 100644 --- a/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php @@ -12,8 +12,8 @@ namespace Symfony\Component\Config\Definition\Builder; use Symfony\Component\Config\Definition\ArrayNode; -use Symfony\Component\Config\Definition\PrototypedArrayNode; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; +use Symfony\Component\Config\Definition\PrototypedArrayNode; /** * This class provides a fluent interface for defining an array node. @@ -48,9 +48,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition } /** - * Sets a custom children builder. - * - * @param NodeBuilder $builder A custom NodeBuilder + * {@inheritdoc} */ public function setBuilder(NodeBuilder $builder) { @@ -58,9 +56,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition } /** - * Returns a builder to add children nodes. - * - * @return NodeBuilder + * {@inheritdoc} */ public function children() { @@ -70,7 +66,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition /** * Sets a prototype for child nodes. * - * @param string $type the type of node + * @param string $type The type of node * * @return NodeDefinition */ @@ -79,6 +75,62 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this); } + /** + * @return VariableNodeDefinition + */ + public function variablePrototype() + { + return $this->prototype('variable'); + } + + /** + * @return ScalarNodeDefinition + */ + public function scalarPrototype() + { + return $this->prototype('scalar'); + } + + /** + * @return BooleanNodeDefinition + */ + public function booleanPrototype() + { + return $this->prototype('boolean'); + } + + /** + * @return IntegerNodeDefinition + */ + public function integerPrototype() + { + return $this->prototype('integer'); + } + + /** + * @return FloatNodeDefinition + */ + public function floatPrototype() + { + return $this->prototype('float'); + } + + /** + * @return ArrayNodeDefinition + */ + public function arrayPrototype() + { + return $this->prototype('array'); + } + + /** + * @return EnumNodeDefinition + */ + public function enumPrototype() + { + return $this->prototype('enum'); + } + /** * Adds the default value if the node is not set in the configuration. * @@ -98,10 +150,10 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition /** * Adds children with a default value when none are defined. * - * @param int|string|array|null $children The number of children|The child name|The children names to be added - * * 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($children = null) @@ -312,19 +364,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition } /** - * Appends a node definition. - * - * $node = new ArrayNodeDefinition() - * ->children() - * ->scalarNode('foo')->end() - * ->scalarNode('baz')->end() - * ->end() - * ->append($this->getBarNodeDefinition()) - * ; - * - * @param NodeDefinition $node A NodeDefinition instance - * - * @return $this + * {@inheritdoc} */ public function append(NodeDefinition $node) { @@ -372,6 +412,10 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition $node->setKeyAttribute($this->key, $this->removeKeyItem); } + if (false === $this->allowEmptyValue) { + @trigger_error(sprintf('Using %s::cannotBeEmpty() at path "%s" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.', __CLASS__, $node->getPath()), E_USER_DEPRECATED); + } + if (true === $this->atLeastOne) { $node->setMinNumberOfElements(1); } @@ -397,6 +441,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition $node->addEquivalentValue(false, $this->falseEquivalent); $node->setPerformDeepMerging($this->performDeepMerging); $node->setRequired($this->required); + $node->setDeprecated($this->deprecationMessage); $node->setIgnoreExtraKeys($this->ignoreExtraKeys, $this->removeExtraKeys); $node->setNormalizeKeys($this->normalizeKeys); @@ -420,8 +465,6 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition /** * Validate the configuration of a concrete node. * - * @param ArrayNode $node The related node - * * @throws InvalidDefinitionException */ protected function validateConcreteNode(ArrayNode $node) @@ -429,35 +472,29 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition $path = $node->getPath(); if (null !== $this->key) { - throw new InvalidDefinitionException( - sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s"', $path)); + } + + if (false === $this->allowEmptyValue) { + @trigger_error(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s". In 4.0 it will throw an exception.', $path), E_USER_DEPRECATED); } if (true === $this->atLeastOne) { - throw new InvalidDefinitionException( - sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s"', $path) - ); + 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) - ); + 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) - ); + throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s"', $path)); } } /** * Validate the configuration of a prototype node. * - * @param PrototypedArrayNode $node The related node - * * @throws InvalidDefinitionException */ protected function validatePrototypeNode(PrototypedArrayNode $node) @@ -465,28 +502,20 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition $path = $node->getPath(); if ($this->addDefaults) { - throw new InvalidDefinitionException( - sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s"', $path) - ); + 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) - ); + 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 && (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) - ); + 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)); } } }