X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FDefinition%2FPrototypedArrayNode.php;h=eddcb32a77871b2c942b7fd2680b781e00b58ad3;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=1c3c2188326bef3ebd0e10479b8bb51a86ef01a8;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/config/Definition/PrototypedArrayNode.php b/vendor/symfony/config/Definition/PrototypedArrayNode.php index 1c3c21883..eddcb32a7 100644 --- a/vendor/symfony/config/Definition/PrototypedArrayNode.php +++ b/vendor/symfony/config/Definition/PrototypedArrayNode.php @@ -11,10 +11,10 @@ namespace Symfony\Component\Config\Definition; -use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Exception\DuplicateKeyException; -use Symfony\Component\Config\Definition\Exception\UnsetKeyException; use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; +use Symfony\Component\Config\Definition\Exception\UnsetKeyException; /** * Represents a prototyped Array node in the config tree. @@ -94,7 +94,7 @@ class PrototypedArrayNode extends ArrayNode */ public function setDefaultValue($value) { - if (!is_array($value)) { + if (!\is_array($value)) { throw new \InvalidArgumentException($this->getPath().': the default value of an array node has to be an array.'); } @@ -102,9 +102,7 @@ class PrototypedArrayNode extends ArrayNode } /** - * Checks if the node has a default value. - * - * @return bool + * {@inheritdoc} */ public function hasDefaultValue() { @@ -121,17 +119,15 @@ class PrototypedArrayNode extends ArrayNode if (null === $children) { $this->defaultChildren = array('defaults'); } else { - $this->defaultChildren = is_int($children) && $children > 0 ? range(1, $children) : (array) $children; + $this->defaultChildren = \is_int($children) && $children > 0 ? range(1, $children) : (array) $children; } } /** - * Retrieves the default value. + * {@inheritdoc} * * The default value could be either explicited or derived from the prototype * default value. - * - * @return array The default value */ public function getDefaultValue() { @@ -150,8 +146,6 @@ class PrototypedArrayNode extends ArrayNode /** * Sets the node prototype. - * - * @param PrototypeNodeInterface $node */ public function setPrototype(PrototypeNodeInterface $node) { @@ -171,8 +165,6 @@ class PrototypedArrayNode extends ArrayNode /** * Disable adding concrete children for prototyped nodes. * - * @param NodeInterface $node The child node to add - * * @throws Exception */ public function addChild(NodeInterface $node) @@ -193,8 +185,7 @@ class PrototypedArrayNode extends ArrayNode 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 ($value as $k => $v) { @@ -206,9 +197,8 @@ class PrototypedArrayNode extends ArrayNode } } - if (count($value) < $this->minNumberOfElements) { - $msg = sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements); - $ex = new InvalidConfigurationException($msg); + if (\count($value) < $this->minNumberOfElements) { + $ex = new InvalidConfigurationException(sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements)); $ex->setPath($this->getPath()); throw $ex; @@ -235,13 +225,12 @@ class PrototypedArrayNode extends ArrayNode $value = $this->remapXml($value); - $isAssoc = array_keys($value) !== range(0, count($value) - 1); + $isAssoc = array_keys($value) !== range(0, \count($value) - 1); $normalized = array(); foreach ($value as $k => $v) { - if (null !== $this->keyAttribute && is_array($v)) { - if (!isset($v[$this->keyAttribute]) && is_int($k) && !$isAssoc) { - $msg = sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath()); - $ex = new InvalidConfigurationException($msg); + if (null !== $this->keyAttribute && \is_array($v)) { + if (!isset($v[$this->keyAttribute]) && \is_int($k) && !$isAssoc) { + $ex = new InvalidConfigurationException(sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -260,9 +249,9 @@ class PrototypedArrayNode extends ArrayNode $valuePrototype = current($this->valuePrototypes) ?: clone $children['value']; $valuePrototype->parent = $this; $originalClosures = $this->prototype->normalizationClosures; - if (is_array($originalClosures)) { + if (\is_array($originalClosures)) { $valuePrototypeClosures = $valuePrototype->normalizationClosures; - $valuePrototype->normalizationClosures = is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures; + $valuePrototype->normalizationClosures = \is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures; } $this->valuePrototypes[$k] = $valuePrototype; } @@ -270,8 +259,7 @@ class PrototypedArrayNode extends ArrayNode } if (array_key_exists($k, $normalized)) { - $msg = sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()); - $ex = new DuplicateKeyException($msg); + $ex = new DuplicateKeyException(sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -322,11 +310,7 @@ class PrototypedArrayNode extends ArrayNode // 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.', - $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.', $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -350,27 +334,31 @@ class PrototypedArrayNode extends ArrayNode * one is same as this->keyAttribute and the other is 'value', then the prototype will be different. * * For example, assume $this->keyAttribute is 'name' and the value array is as follows: - * array( + * * array( - * 'name' => 'name001', - * 'value' => 'value001' + * array( + * 'name' => 'name001', + * 'value' => 'value001' + * ) * ) - * ) * * Now, the key is 0 and the child node is: - * array( - * 'name' => 'name001', - * 'value' => 'value001' - * ) + * + * array( + * 'name' => 'name001', + * 'value' => 'value001' + * ) * * When normalizing the value array, the 'name' element will removed from the child node * and its value becomes the new key of the child node: - * array( - * 'name001' => array('value' => 'value001') - * ) + * + * array( + * 'name001' => array('value' => 'value001') + * ) * * Now only 'value' element is left in the child node which can be further simplified into a string: - * array('name001' => 'value001') + * + * array('name001' => 'value001') * * Now, the key becomes 'name001' and the child node becomes 'value001' and * the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance.