*/
protected function preNormalize($value)
{
- if (!$this->normalizeKeys || !is_array($value)) {
+ if (!$this->normalizeKeys || !\is_array($value)) {
return $value;
}
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;
*/
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;
// 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;