@@ -32,11 +32,11 @@ |
||
32 | 32 | // Trim the trailing period of the previous message. We only want 1 period remove so no rtrim... |
33 | 33 | if ('.' === \substr($previous->getMessage(), -1)) { |
34 | 34 | $trimmedMessage = \substr($previous->getMessage(), 0, -1); |
35 | - $message .= \sprintf('%s', $trimmedMessage) . ' in '; |
|
35 | + $message .= \sprintf('%s', $trimmedMessage).' in '; |
|
36 | 36 | } else { |
37 | - $message .= \sprintf('%s', $previous->getMessage()) . ' in '; |
|
37 | + $message .= \sprintf('%s', $previous->getMessage()).' in '; |
|
38 | 38 | } |
39 | - $message .= $resource . ' '; |
|
39 | + $message .= $resource.' '; |
|
40 | 40 | // show tweaked trace to complete the human readable sentence |
41 | 41 | if (null === $sourceResource) { |
42 | 42 | $message .= \sprintf('(which is loaded in resource "%s")', $this->varToString($resource)); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | if (\is_string($resource) && \strlen($resource) !== ($i = \strcspn($resource, '*?{['))) { |
68 | 68 | $ret = []; |
69 | 69 | $isSubpath = 0 !== $i && \false !== \strpos(\substr($resource, 0, $i), '/'); |
70 | - foreach ($this->glob($resource, \false, $_, $ignoreErrors || !$isSubpath) as $path => $info) { |
|
70 | + foreach ($this->glob($resource, \false, $_, $ignoreErrors || ! $isSubpath) as $path => $info) { |
|
71 | 71 | if (null !== ($res = $this->doImport($path, 'glob' === $type ? null : $type, $ignoreErrors, $sourceResource))) { |
72 | 72 | $ret[] = $res; |
73 | 73 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $pattern = ''; |
90 | 90 | } elseif (0 === $i || \false === \strpos(\substr($pattern, 0, $i), '/')) { |
91 | 91 | $prefix = '.'; |
92 | - $pattern = '/' . $pattern; |
|
92 | + $pattern = '/'.$pattern; |
|
93 | 93 | } else { |
94 | 94 | $prefix = \dirname(\substr($pattern, 0, 1 + $i)); |
95 | 95 | $pattern = \substr($pattern, \strlen($prefix)); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | try { |
98 | 98 | $prefix = $this->locator->locate($prefix, $this->currentDir, \true); |
99 | 99 | } catch (FileLocatorFileNotFoundException $e) { |
100 | - if (!$ignoreErrors) { |
|
100 | + if ( ! $ignoreErrors) { |
|
101 | 101 | throw $e; |
102 | 102 | } |
103 | 103 | $resource = []; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } catch (FileLoaderImportCircularReferenceException $e) { |
140 | 140 | throw $e; |
141 | 141 | } catch (\Exception $e) { |
142 | - if (!$ignoreErrors) { |
|
142 | + if ( ! $ignoreErrors) { |
|
143 | 143 | // prevent embedded imports from nesting multiple exceptions |
144 | 144 | if ($e instanceof FileLoaderLoadException) { |
145 | 145 | throw $e; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | */ |
48 | 48 | public function isFresh() |
49 | 49 | { |
50 | - if (!$this->debug && \is_file($this->getPath())) { |
|
50 | + if ( ! $this->debug && \is_file($this->getPath())) { |
|
51 | 51 | return \true; |
52 | 52 | } |
53 | 53 | return parent::isFresh(); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function parse($content, $schemaOrCallable = null) |
45 | 45 | { |
46 | - if (!\extension_loaded('dom')) { |
|
46 | + if ( ! \extension_loaded('dom')) { |
|
47 | 47 | throw new \RuntimeException('Extension DOM is required.'); |
48 | 48 | } |
49 | 49 | $internalErrors = \libxml_use_internal_errors(\true); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | \libxml_clear_errors(); |
54 | 54 | $dom = new \DOMDocument(); |
55 | 55 | $dom->validateOnParse = \true; |
56 | - if (!$dom->loadXML($content, \LIBXML_NONET | (\defined('LIBXML_COMPACT') ? \LIBXML_COMPACT : 0))) { |
|
56 | + if ( ! $dom->loadXML($content, \LIBXML_NONET | (\defined('LIBXML_COMPACT') ? \LIBXML_COMPACT : 0))) { |
|
57 | 57 | if (\LIBXML_VERSION < 20900) { |
58 | 58 | \libxml_disable_entity_loader($disableEntities); |
59 | 59 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | } catch (\Exception $e) { |
80 | 80 | $valid = \false; |
81 | 81 | } |
82 | - } elseif (!\is_array($schemaOrCallable) && \is_file((string) $schemaOrCallable)) { |
|
82 | + } elseif ( ! \is_array($schemaOrCallable) && \is_file((string) $schemaOrCallable)) { |
|
83 | 83 | $schemaSource = \file_get_contents((string) $schemaOrCallable); |
84 | 84 | $valid = @$dom->schemaValidateSource($schemaSource); |
85 | 85 | } else { |
86 | 86 | \libxml_use_internal_errors($internalErrors); |
87 | 87 | throw new XmlParsingException('The schemaOrCallable argument has to be a valid path to XSD file or callable.'); |
88 | 88 | } |
89 | - if (!$valid) { |
|
89 | + if ( ! $valid) { |
|
90 | 90 | $messages = static::getXmlErrors($internalErrors); |
91 | 91 | if (empty($messages)) { |
92 | 92 | throw new InvalidXmlException('The XML is not valid.', 0, $e); |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function loadFile($file, $schemaOrCallable = null) |
114 | 114 | { |
115 | - if (!\is_file($file)) { |
|
115 | + if ( ! \is_file($file)) { |
|
116 | 116 | throw new \InvalidArgumentException(\sprintf('Resource "%s" is not a file.', $file)); |
117 | 117 | } |
118 | - if (!\is_readable($file)) { |
|
118 | + if ( ! \is_readable($file)) { |
|
119 | 119 | throw new \InvalidArgumentException(\sprintf('File "%s" is not readable.', $file)); |
120 | 120 | } |
121 | 121 | $content = @\file_get_contents($file); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $empty = \true; |
155 | 155 | $config = []; |
156 | 156 | foreach ($element->attributes as $name => $node) { |
157 | - if ($checkPrefix && !\in_array((string) $node->prefix, ['', $prefix], \true)) { |
|
157 | + if ($checkPrefix && ! \in_array((string) $node->prefix, ['', $prefix], \true)) { |
|
158 | 158 | continue; |
159 | 159 | } |
160 | 160 | $config[$name] = static::phpize($node->value); |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | } |
170 | 170 | } elseif ($checkPrefix && $prefix != (string) $node->prefix) { |
171 | 171 | continue; |
172 | - } elseif (!$node instanceof \DOMComment) { |
|
172 | + } elseif ( ! $node instanceof \DOMComment) { |
|
173 | 173 | $value = static::convertDomElementToArray($node, $checkPrefix); |
174 | 174 | $key = $node->localName; |
175 | 175 | if (isset($config[$key])) { |
176 | - if (!\is_array($config[$key]) || !\is_int(\key($config[$key]))) { |
|
176 | + if ( ! \is_array($config[$key]) || ! \is_int(\key($config[$key]))) { |
|
177 | 177 | $config[$key] = [$config[$key]]; |
178 | 178 | } |
179 | 179 | $config[$key][] = $value; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $config = $value; |
192 | 192 | } |
193 | 193 | } |
194 | - return !$empty ? $config : null; |
|
194 | + return ! $empty ? $config : null; |
|
195 | 195 | } |
196 | 196 | /** |
197 | 197 | * Converts an xml value to a PHP type. |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | return \true; |
220 | 220 | case 'false' === $lowercaseValue: |
221 | 221 | return \false; |
222 | - case isset($value[1]) && '0b' == $value[0] . $value[1] && \preg_match('/^0b[01]*$/', $value): |
|
222 | + case isset($value[1]) && '0b' == $value[0].$value[1] && \preg_match('/^0b[01]*$/', $value): |
|
223 | 223 | return \bindec($value); |
224 | 224 | case \is_numeric($value): |
225 | - return '0x' === $value[0] . $value[1] ? \hexdec($value) : (float) $value; |
|
225 | + return '0x' === $value[0].$value[1] ? \hexdec($value) : (float) $value; |
|
226 | 226 | case \preg_match('/^0x[0-9a-f]++$/i', $value): |
227 | 227 | return \hexdec($value); |
228 | 228 | case \preg_match('/^[+-]?[0-9]+(\\.[0-9]+)?$/', $value): |
@@ -72,13 +72,13 @@ |
||
72 | 72 | public static function normalizeConfig($config, $key, $plural = null) |
73 | 73 | { |
74 | 74 | if (null === $plural) { |
75 | - $plural = $key . 's'; |
|
75 | + $plural = $key.'s'; |
|
76 | 76 | } |
77 | 77 | if (isset($config[$plural])) { |
78 | 78 | return $config[$plural]; |
79 | 79 | } |
80 | 80 | if (isset($config[$key])) { |
81 | - if (\is_string($config[$key]) || !\is_int(\key($config[$key]))) { |
|
81 | + if (\is_string($config[$key]) || ! \is_int(\key($config[$key]))) { |
|
82 | 82 | // only one |
83 | 83 | return [$config[$key]]; |
84 | 84 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | if (\is_int($value)) { |
28 | 28 | $value = (float) $value; |
29 | 29 | } |
30 | - if (!\is_float($value)) { |
|
30 | + if ( ! \is_float($value)) { |
|
31 | 31 | $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), \gettype($value))); |
32 | 32 | if ($hint = $this->getInfo()) { |
33 | 33 | $ex->addHint($hint); |
@@ -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); |