@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $path = $this->name; |
| 225 | 225 | if (null !== $this->parent) { |
| 226 | - $path = $this->parent->getPath() . '.' . $path; |
|
| 226 | + $path = $this->parent->getPath().'.'.$path; |
|
| 227 | 227 | } |
| 228 | 228 | return $path; |
| 229 | 229 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public final function merge($leftSide, $rightSide) |
| 234 | 234 | { |
| 235 | - if (!$this->allowOverwrite) { |
|
| 235 | + if ( ! $this->allowOverwrite) { |
|
| 236 | 236 | throw new ForbiddenOverwriteException(\sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.', $this->getPath())); |
| 237 | 237 | } |
| 238 | 238 | $this->validateType($leftSide); |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | } catch (Exception $e) { |
| 296 | 296 | throw $e; |
| 297 | 297 | } catch (\Exception $e) { |
| 298 | - throw new InvalidConfigurationException(\sprintf('Invalid configuration for path "%s": ', $this->getPath()) . $e->getMessage(), $e->getCode(), $e); |
|
| 298 | + throw new InvalidConfigurationException(\sprintf('Invalid configuration for path "%s": ', $this->getPath()).$e->getMessage(), $e->getCode(), $e); |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | return $value; |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | protected function finalizeValue($value) |
| 36 | 36 | { |
| 37 | 37 | $value = parent::finalizeValue($value); |
| 38 | - if (!\in_array($value, $this->values, \true)) { |
|
| 38 | + if ( ! \in_array($value, $this->values, \true)) { |
|
| 39 | 39 | $ex = new InvalidConfigurationException(\sprintf('The value %s is not allowed for path "%s". Permissible values: %s', \json_encode($value), $this->getPath(), \implode(', ', \array_map('json_encode', $this->values)))); |
| 40 | 40 | $ex->setPath($this->getPath()); |
| 41 | 41 | throw $ex; |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | protected function validateType($value) |
| 25 | 25 | { |
| 26 | - if (!\is_int($value)) { |
|
| 26 | + if ( ! \is_int($value)) { |
|
| 27 | 27 | $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected int, but got %s.', $this->getPath(), \gettype($value))); |
| 28 | 28 | if ($hint = $this->getInfo()) { |
| 29 | 29 | $ex->addHint($hint); |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function setDefaultValue($value) |
| 90 | 90 | { |
| 91 | - if (!\is_array($value)) { |
|
| 92 | - throw new \InvalidArgumentException($this->getPath() . ': the default value of an array node has to be an array.'); |
|
| 91 | + if ( ! \is_array($value)) { |
|
| 92 | + throw new \InvalidArgumentException($this->getPath().': the default value of an array node has to be an array.'); |
|
| 93 | 93 | } |
| 94 | 94 | $this->defaultValue = $value; |
| 95 | 95 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $normalized = []; |
| 207 | 207 | foreach ($value as $k => $v) { |
| 208 | 208 | if (null !== $this->keyAttribute && \is_array($v)) { |
| 209 | - if (!isset($v[$this->keyAttribute]) && \is_int($k) && !$isAssoc) { |
|
| 209 | + if ( ! isset($v[$this->keyAttribute]) && \is_int($k) && ! $isAssoc) { |
|
| 210 | 210 | $ex = new InvalidConfigurationException(\sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath())); |
| 211 | 211 | $ex->setPath($this->getPath()); |
| 212 | 212 | throw $ex; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | // finalization pass will take care of removing this key entirely |
| 265 | 265 | return \false; |
| 266 | 266 | } |
| 267 | - if (\false === $leftSide || !$this->performDeepMerging) { |
|
| 267 | + if (\false === $leftSide || ! $this->performDeepMerging) { |
|
| 268 | 268 | return $rightSide; |
| 269 | 269 | } |
| 270 | 270 | foreach ($rightSide as $k => $v) { |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | continue; |
| 275 | 275 | } |
| 276 | 276 | // no conflict |
| 277 | - if (!\array_key_exists($k, $leftSide)) { |
|
| 278 | - if (!$this->allowNewKeys) { |
|
| 277 | + if ( ! \array_key_exists($k, $leftSide)) { |
|
| 278 | + if ( ! $this->allowNewKeys) { |
|
| 279 | 279 | $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())); |
| 280 | 280 | $ex->setPath($this->getPath()); |
| 281 | 281 | throw $ex; |
@@ -244,7 +244,7 @@ |
||
| 244 | 244 | */ |
| 245 | 245 | public function canBeEnabled() |
| 246 | 246 | { |
| 247 | - $this->addDefaultsIfNotSet()->treatFalseLike(['enabled' => \false])->treatTrueLike(['enabled' => \true])->treatNullLike(['enabled' => \true])->beforeNormalization()->ifArray()->then(function ($v) { |
|
| 247 | + $this->addDefaultsIfNotSet()->treatFalseLike(['enabled' => \false])->treatTrueLike(['enabled' => \true])->treatNullLike(['enabled' => \true])->beforeNormalization()->ifArray()->then(function($v) { |
|
| 248 | 248 | $v['enabled'] = isset($v['enabled']) ? $v['enabled'] : \true; |
| 249 | 249 | return $v; |
| 250 | 250 | })->end()->children()->booleanNode('enabled')->defaultFalse(); |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public function denyOverwrite($deny = \true) |
| 47 | 47 | { |
| 48 | - $this->allowOverwrite = !$deny; |
|
| 48 | + $this->allowOverwrite = ! $deny; |
|
| 49 | 49 | return $this; |
| 50 | 50 | } |
| 51 | 51 | /** |
@@ -192,11 +192,11 @@ |
||
| 192 | 192 | protected function getNodeClass($type) |
| 193 | 193 | { |
| 194 | 194 | $type = \strtolower($type); |
| 195 | - if (!isset($this->nodeMapping[$type])) { |
|
| 195 | + if ( ! isset($this->nodeMapping[$type])) { |
|
| 196 | 196 | throw new \RuntimeException(\sprintf('The node type "%s" is not registered.', $type)); |
| 197 | 197 | } |
| 198 | 198 | $class = $this->nodeMapping[$type]; |
| 199 | - if (!\class_exists($class)) { |
|
| 199 | + if ( ! \class_exists($class)) { |
|
| 200 | 200 | throw new \RuntimeException(\sprintf('The node class "%s" does not exist.', $class)); |
| 201 | 201 | } |
| 202 | 202 | return $class; |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | public function remap($key, $plural = null) |
| 36 | 36 | { |
| 37 | - $this->remappings[] = [$key, null === $plural ? $key . 's' : $plural]; |
|
| 37 | + $this->remappings[] = [$key, null === $plural ? $key.'s' : $plural]; |
|
| 38 | 38 | return $this; |
| 39 | 39 | } |
| 40 | 40 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function always(\Closure $then = null) |
| 35 | 35 | { |
| 36 | - $this->ifPart = function ($v) { |
|
| 36 | + $this->ifPart = function($v) { |
|
| 37 | 37 | return \true; |
| 38 | 38 | }; |
| 39 | 39 | if (null !== $then) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public function ifTrue(\Closure $closure = null) |
| 52 | 52 | { |
| 53 | 53 | if (null === $closure) { |
| 54 | - $closure = function ($v) { |
|
| 54 | + $closure = function($v) { |
|
| 55 | 55 | return \true === $v; |
| 56 | 56 | }; |
| 57 | 57 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function ifString() |
| 67 | 67 | { |
| 68 | - $this->ifPart = function ($v) { |
|
| 68 | + $this->ifPart = function($v) { |
|
| 69 | 69 | return \is_string($v); |
| 70 | 70 | }; |
| 71 | 71 | return $this; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function ifNull() |
| 79 | 79 | { |
| 80 | - $this->ifPart = function ($v) { |
|
| 80 | + $this->ifPart = function($v) { |
|
| 81 | 81 | return null === $v; |
| 82 | 82 | }; |
| 83 | 83 | return $this; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function ifEmpty() |
| 91 | 91 | { |
| 92 | - $this->ifPart = function ($v) { |
|
| 92 | + $this->ifPart = function($v) { |
|
| 93 | 93 | return empty($v); |
| 94 | 94 | }; |
| 95 | 95 | return $this; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function ifArray() |
| 103 | 103 | { |
| 104 | - $this->ifPart = function ($v) { |
|
| 104 | + $this->ifPart = function($v) { |
|
| 105 | 105 | return \is_array($v); |
| 106 | 106 | }; |
| 107 | 107 | return $this; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function ifInArray(array $array) |
| 115 | 115 | { |
| 116 | - $this->ifPart = function ($v) use($array) { |
|
| 116 | + $this->ifPart = function($v) use($array) { |
|
| 117 | 117 | return \in_array($v, $array, \true); |
| 118 | 118 | }; |
| 119 | 119 | return $this; |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function ifNotInArray(array $array) |
| 127 | 127 | { |
| 128 | - $this->ifPart = function ($v) use($array) { |
|
| 129 | - return !\in_array($v, $array, \true); |
|
| 128 | + $this->ifPart = function($v) use($array) { |
|
| 129 | + return ! \in_array($v, $array, \true); |
|
| 130 | 130 | }; |
| 131 | 131 | return $this; |
| 132 | 132 | } |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function castToArray() |
| 139 | 139 | { |
| 140 | - $this->ifPart = function ($v) { |
|
| 141 | - return !\is_array($v); |
|
| 140 | + $this->ifPart = function($v) { |
|
| 141 | + return ! \is_array($v); |
|
| 142 | 142 | }; |
| 143 | - $this->thenPart = function ($v) { |
|
| 143 | + $this->thenPart = function($v) { |
|
| 144 | 144 | return [$v]; |
| 145 | 145 | }; |
| 146 | 146 | return $this; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function thenEmptyArray() |
| 164 | 164 | { |
| 165 | - $this->thenPart = function ($v) { |
|
| 165 | + $this->thenPart = function($v) { |
|
| 166 | 166 | return []; |
| 167 | 167 | }; |
| 168 | 168 | return $this; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function thenInvalid($message) |
| 182 | 182 | { |
| 183 | - $this->thenPart = function ($v) use($message) { |
|
| 183 | + $this->thenPart = function($v) use($message) { |
|
| 184 | 184 | throw new \InvalidArgumentException(\sprintf($message, \json_encode($v))); |
| 185 | 185 | }; |
| 186 | 186 | return $this; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function thenUnset() |
| 196 | 196 | { |
| 197 | - $this->thenPart = function ($v) { |
|
| 197 | + $this->thenPart = function($v) { |
|
| 198 | 198 | throw new UnsetKeyException('Unsetting key.'); |
| 199 | 199 | }; |
| 200 | 200 | return $this; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | if ($expr instanceof self) { |
| 230 | 230 | $if = $expr->ifPart; |
| 231 | 231 | $then = $expr->thenPart; |
| 232 | - $expressions[$k] = function ($v) use($if, $then) { |
|
| 232 | + $expressions[$k] = function($v) use($if, $then) { |
|
| 233 | 233 | return $if($v) ? $then($v) : $v; |
| 234 | 234 | }; |
| 235 | 235 | } |