*/
protected function preNormalize($value)
{
- if (!$this->normalizeKeys || !is_array($value)) {
+ if (!$this->normalizeKeys || !\is_array($value)) {
return $value;
}
/**
* 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)
{
}
/**
- * Sets the node Name.
- *
- * @param string $name The node's name
+ * {@inheritdoc}
*/
public function setName($name)
{
}
/**
- * Checks if the node has a default value.
- *
- * @return bool
+ * {@inheritdoc}
*/
public function hasDefaultValue()
{
}
/**
- * Retrieves the default value.
- *
- * @return array The default value
- *
- * @throws \RuntimeException if the node has no default value
+ * {@inheritdoc}
*/
public function getDefaultValue()
{
/**
* 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])) {
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;
continue;
}
+ if ($child->isDeprecated()) {
+ @trigger_error($child->getDeprecationMessage($name, $this->getPath()), E_USER_DEPRECATED);
+ }
+
try {
$value[$name] = $child->finalize($value[$name]);
} catch (UnsetKeyException $e) {
*/
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);
}
}
// 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;
*/
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;
}
// 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;