@@ -35,11 +35,11 @@ |
||
35 | 35 | */ |
36 | 36 | public function addHint($hint) |
37 | 37 | { |
38 | - if (!$this->containsHints) { |
|
39 | - $this->message .= "\nHint: " . $hint; |
|
38 | + if ( ! $this->containsHints) { |
|
39 | + $this->message .= "\nHint: ".$hint; |
|
40 | 40 | $this->containsHints = \true; |
41 | 41 | } else { |
42 | - $this->message .= ', ' . $hint; |
|
42 | + $this->message .= ', '.$hint; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected function preNormalize($value) |
46 | 46 | { |
47 | - if (!$this->normalizeKeys || !\is_array($value)) { |
|
47 | + if ( ! $this->normalizeKeys || ! \is_array($value)) { |
|
48 | 48 | return $value; |
49 | 49 | } |
50 | 50 | $normalized = []; |
51 | 51 | foreach ($value as $k => $v) { |
52 | - if (\false !== \strpos($k, '-') && \false === \strpos($k, '_') && !\array_key_exists($normalizedKey = \str_replace('-', '_', $k), $value)) { |
|
52 | + if (\false !== \strpos($k, '-') && \false === \strpos($k, '_') && ! \array_key_exists($normalizedKey = \str_replace('-', '_', $k), $value)) { |
|
53 | 53 | $normalized[$normalizedKey] = $v; |
54 | 54 | } else { |
55 | 55 | $normalized[$k] = $v; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function getDefaultValue() |
153 | 153 | { |
154 | - if (!$this->hasDefaultValue()) { |
|
154 | + if ( ! $this->hasDefaultValue()) { |
|
155 | 155 | throw new \RuntimeException(\sprintf('The node at path "%s" has no default value.', $this->getPath())); |
156 | 156 | } |
157 | 157 | $defaults = []; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | public function addChild(NodeInterface $node) |
172 | 172 | { |
173 | 173 | $name = $node->getName(); |
174 | - if (!\strlen($name)) { |
|
174 | + if ( ! \strlen($name)) { |
|
175 | 175 | throw new \InvalidArgumentException('Child nodes must be named.'); |
176 | 176 | } |
177 | 177 | if (isset($this->children[$name])) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | throw new UnsetKeyException(\sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), \json_encode($value))); |
196 | 196 | } |
197 | 197 | foreach ($this->children as $name => $child) { |
198 | - if (!\array_key_exists($name, $value)) { |
|
198 | + if ( ! \array_key_exists($name, $value)) { |
|
199 | 199 | if ($child->isRequired()) { |
200 | 200 | $ex = new InvalidConfigurationException(\sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath())); |
201 | 201 | $ex->setPath($this->getPath()); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function validateType($value) |
228 | 228 | { |
229 | - if (!\is_array($value) && (!$this->allowFalse || \false !== $value)) { |
|
229 | + if ( ! \is_array($value) && ( ! $this->allowFalse || \false !== $value)) { |
|
230 | 230 | $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), \gettype($value))); |
231 | 231 | if ($hint = $this->getInfo()) { |
232 | 232 | $ex->addHint($hint); |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | } catch (UnsetKeyException $e) { |
259 | 259 | } |
260 | 260 | unset($value[$name]); |
261 | - } elseif (!$this->removeExtraKeys) { |
|
261 | + } elseif ( ! $this->removeExtraKeys) { |
|
262 | 262 | $normalized[$name] = $val; |
263 | 263 | } |
264 | 264 | } |
265 | 265 | // if extra fields are present, throw exception |
266 | - if (\count($value) && !$this->ignoreExtraKeys) { |
|
266 | + if (\count($value) && ! $this->ignoreExtraKeys) { |
|
267 | 267 | $ex = new InvalidConfigurationException(\sprintf('Unrecognized option%s "%s" under "%s"', 1 === \count($value) ? '' : 's', \implode(', ', \array_keys($value)), $this->getPath())); |
268 | 268 | $ex->setPath($this->getPath()); |
269 | 269 | throw $ex; |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | protected function remapXml($value) |
281 | 281 | { |
282 | 282 | foreach ($this->xmlRemappings as list($singular, $plural)) { |
283 | - if (!isset($value[$singular])) { |
|
283 | + if ( ! isset($value[$singular])) { |
|
284 | 284 | continue; |
285 | 285 | } |
286 | 286 | $value[$plural] = Processor::normalizeConfig($value, $singular, $plural); |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | // finalization pass will take care of removing this key entirely |
307 | 307 | return \false; |
308 | 308 | } |
309 | - if (\false === $leftSide || !$this->performDeepMerging) { |
|
309 | + if (\false === $leftSide || ! $this->performDeepMerging) { |
|
310 | 310 | return $rightSide; |
311 | 311 | } |
312 | 312 | foreach ($rightSide as $k => $v) { |
313 | 313 | // no conflict |
314 | - if (!\array_key_exists($k, $leftSide)) { |
|
315 | - if (!$this->allowNewKeys) { |
|
314 | + if ( ! \array_key_exists($k, $leftSide)) { |
|
315 | + if ( ! $this->allowNewKeys) { |
|
316 | 316 | $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())); |
317 | 317 | $ex->setPath($this->getPath()); |
318 | 318 | throw $ex; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $leftSide[$k] = $v; |
321 | 321 | continue; |
322 | 322 | } |
323 | - if (!isset($this->children[$k])) { |
|
323 | + if ( ! isset($this->children[$k])) { |
|
324 | 324 | throw new \RuntimeException('merge() expects a normalized config array.'); |
325 | 325 | } |
326 | 326 | $leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v); |
@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | protected function validateType($value) |
32 | 32 | { |
33 | - if (!\is_scalar($value) && null !== $value) { |
|
33 | + if ( ! \is_scalar($value) && null !== $value) { |
|
34 | 34 | $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected scalar, but got %s.', $this->getPath(), \gettype($value))); |
35 | 35 | if ($hint = $this->getInfo()) { |
36 | 36 | $ex->addHint($hint); |
@@ -71,7 +71,7 @@ |
||
71 | 71 | */ |
72 | 72 | protected function finalizeValue($value) |
73 | 73 | { |
74 | - if (!$this->allowEmptyValue && $this->isValueEmpty($value)) { |
|
74 | + if ( ! $this->allowEmptyValue && $this->isValueEmpty($value)) { |
|
75 | 75 | $ex = new InvalidConfigurationException(\sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), \json_encode($value))); |
76 | 76 | if ($hint = $this->getInfo()) { |
77 | 77 | $ex->addHint($hint); |
@@ -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(); |