X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FDefinition%2FPrototypedArrayNode.php;h=eddcb32a77871b2c942b7fd2680b781e00b58ad3;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=d377b73e6c8020b054b63db5ff939320494b633b;hpb=af6d1fb995500ae68849458ee10d66abbdcfb252;p=yaffs-website diff --git a/vendor/symfony/config/Definition/PrototypedArrayNode.php b/vendor/symfony/config/Definition/PrototypedArrayNode.php index d377b73e6..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.'); } @@ -119,7 +119,7 @@ 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; } } @@ -185,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) { @@ -198,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; @@ -227,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; @@ -252,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; } @@ -262,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; @@ -314,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; @@ -342,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.