Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / config / Definition / Builder / ArrayNodeDefinition.php
index a1fc1fab0ef78fbd866f2ad2f00a942c805f740b..7a0439f1aba9297b95bdcc4fb6060f4a54cfaad8 100644 (file)
@@ -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)
@@ -434,6 +477,10 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
             );
         }
 
+        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)
@@ -456,8 +503,6 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
     /**
      * Validate the configuration of a prototype node.
      *
-     * @param PrototypedArrayNode $node The related node
-     *
      * @throws InvalidDefinitionException
      */
     protected function validatePrototypeNode(PrototypedArrayNode $node)