X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FDefinition%2FArrayNode.php;h=17d10ffc9bfbdd8372e57a4abfedc2cdea7ca521;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=8320f4aac315e2644a23cf9f406f1e9619872038;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/config/Definition/ArrayNode.php b/vendor/symfony/config/Definition/ArrayNode.php index 8320f4aac..17d10ffc9 100644 --- a/vendor/symfony/config/Definition/ArrayNode.php +++ b/vendor/symfony/config/Definition/ArrayNode.php @@ -52,7 +52,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface */ protected function preNormalize($value) { - if (!$this->normalizeKeys || !is_array($value)) { + if (!$this->normalizeKeys || !\is_array($value)) { return $value; } @@ -82,7 +82,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface /** * Sets the xml remappings that should be performed. * - * @param array $remappings an array of the form array(array(string, string)) + * @param array $remappings An array of the form array(array(string, string)) */ public function setXmlRemappings(array $remappings) { @@ -153,9 +153,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface } /** - * Sets the node Name. - * - * @param string $name The node's name + * {@inheritdoc} */ public function setName($name) { @@ -163,9 +161,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface } /** - * Checks if the node has a default value. - * - * @return bool + * {@inheritdoc} */ public function hasDefaultValue() { @@ -173,11 +169,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface } /** - * Retrieves the default value. - * - * @return array The default value - * - * @throws \RuntimeException if the node has no default value + * {@inheritdoc} */ public function getDefaultValue() { @@ -198,15 +190,13 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface /** * Adds a child node. * - * @param NodeInterface $node The child node to add - * * @throws \InvalidArgumentException when the child node has no name * @throws \InvalidArgumentException when the child node's name is not unique */ public function addChild(NodeInterface $node) { $name = $node->getName(); - if (!strlen($name)) { + if (!\strlen($name)) { throw new \InvalidArgumentException('Child nodes must be named.'); } if (isset($this->children[$name])) { @@ -229,15 +219,13 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface protected function finalizeValue($value) { if (false === $value) { - $msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value)); - throw new UnsetKeyException($msg); + throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value))); } foreach ($this->children as $name => $child) { if (!array_key_exists($name, $value)) { if ($child->isRequired()) { - $msg = sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath()); - $ex = new InvalidConfigurationException($msg); + $ex = new InvalidConfigurationException(sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -250,6 +238,10 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface continue; } + if ($child->isDeprecated()) { + @trigger_error($child->getDeprecationMessage($name, $this->getPath()), E_USER_DEPRECATED); + } + try { $value[$name] = $child->finalize($value[$name]); } catch (UnsetKeyException $e) { @@ -269,12 +261,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface */ protected function validateType($value) { - if (!is_array($value) && (!$this->allowFalse || false !== $value)) { - $ex = new InvalidTypeException(sprintf( - 'Invalid type for path "%s". Expected array, but got %s', - $this->getPath(), - gettype($value) - )); + if (!\is_array($value) && (!$this->allowFalse || false !== $value)) { + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), \gettype($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } @@ -312,9 +300,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface } // if extra fields are present, throw exception - if (count($value) && !$this->ignoreExtraKeys) { - $msg = sprintf('Unrecognized option%s "%s" under "%s"', 1 === count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath()); - $ex = new InvalidConfigurationException($msg); + if (\count($value) && !$this->ignoreExtraKeys) { + $ex = new InvalidConfigurationException(sprintf('Unrecognized option%s "%s" under "%s"', 1 === \count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -332,9 +319,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface */ protected function remapXml($value) { - foreach ($this->xmlRemappings as $transformation) { - list($singular, $plural) = $transformation; - + foreach ($this->xmlRemappings as list($singular, $plural)) { if (!isset($value[$singular])) { continue; } @@ -373,13 +358,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface // no conflict if (!array_key_exists($k, $leftSide)) { if (!$this->allowNewKeys) { - $ex = new InvalidConfigurationException(sprintf( - 'You are not allowed to define new elements for path "%s". ' - .'Please define all elements for this path in one config file. ' - .'If you are trying to overwrite an element, make sure you redefine it ' - .'with the same name.', - $this->getPath() - )); + $ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath())); $ex->setPath($this->getPath()); throw $ex;