@@ -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 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | protected function validateType($value) |
| 25 | 25 | { |
| 26 | - if (!\is_bool($value)) { |
|
| 26 | + if ( ! \is_bool($value)) { |
|
| 27 | 27 | $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected boolean, but got %s.', $this->getPath(), \gettype($value))); |
| 28 | 28 | if ($hint = $this->getInfo()) { |
| 29 | 29 | $ex->addHint($hint); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $rootNode = $node = $configuration->getConfigTreeBuilder()->buildTree(); |
| 35 | 35 | foreach (\explode('.', $path) as $step) { |
| 36 | - if (!$node instanceof ArrayNode) { |
|
| 36 | + if ( ! $node instanceof ArrayNode) { |
|
| 37 | 37 | throw new \UnexpectedValueException(\sprintf('Unable to find node at path "%s.%s".', $rootNode->getName(), $path)); |
| 38 | 38 | } |
| 39 | 39 | /** @var NodeInterface[] $children */ |
@@ -73,15 +73,15 @@ discard block |
||
| 73 | 73 | if ($node instanceof PrototypedArrayNode) { |
| 74 | 74 | $children = $this->getPrototypeChildren($node); |
| 75 | 75 | } |
| 76 | - if (!$children) { |
|
| 76 | + if ( ! $children) { |
|
| 77 | 77 | if ($node->hasDefaultValue() && \count($defaultArray = $node->getDefaultValue())) { |
| 78 | 78 | $default = ''; |
| 79 | - } elseif (!\is_array($example)) { |
|
| 79 | + } elseif ( ! \is_array($example)) { |
|
| 80 | 80 | $default = '[]'; |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | } elseif ($node instanceof EnumNode) { |
| 84 | - $comments[] = 'One of ' . \implode('; ', \array_map('json_encode', $node->getValues())); |
|
| 84 | + $comments[] = 'One of '.\implode('; ', \array_map('json_encode', $node->getValues())); |
|
| 85 | 85 | $default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~'; |
| 86 | 86 | } else { |
| 87 | 87 | $default = '~'; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | if (\is_array($default)) { |
| 91 | 91 | if (\count($defaultArray = $node->getDefaultValue())) { |
| 92 | 92 | $default = ''; |
| 93 | - } elseif (!\is_array($example)) { |
|
| 93 | + } elseif ( ! \is_array($example)) { |
|
| 94 | 94 | $default = '[]'; |
| 95 | 95 | } |
| 96 | 96 | } else { |
@@ -107,36 +107,36 @@ discard block |
||
| 107 | 107 | $comments[] = \sprintf('Deprecated (%s)', $node->getDeprecationMessage($node->getName(), $parentNode ? $parentNode->getPath() : $node->getPath())); |
| 108 | 108 | } |
| 109 | 109 | // example |
| 110 | - if ($example && !\is_array($example)) { |
|
| 111 | - $comments[] = 'Example: ' . $example; |
|
| 110 | + if ($example && ! \is_array($example)) { |
|
| 111 | + $comments[] = 'Example: '.$example; |
|
| 112 | 112 | } |
| 113 | - $default = '' != (string) $default ? ' ' . $default : ''; |
|
| 114 | - $comments = \count($comments) ? '# ' . \implode(', ', $comments) : ''; |
|
| 115 | - $key = $prototypedArray ? '-' : $node->getName() . ':'; |
|
| 113 | + $default = '' != (string) $default ? ' '.$default : ''; |
|
| 114 | + $comments = \count($comments) ? '# '.\implode(', ', $comments) : ''; |
|
| 115 | + $key = $prototypedArray ? '-' : $node->getName().':'; |
|
| 116 | 116 | $text = \rtrim(\sprintf('%-21s%s %s', $key, $default, $comments), ' '); |
| 117 | 117 | if ($info = $node->getInfo()) { |
| 118 | 118 | $this->writeLine(''); |
| 119 | 119 | // indenting multi-line info |
| 120 | - $info = \str_replace("\n", \sprintf("\n%" . $depth * 4 . 's# ', ' '), $info); |
|
| 121 | - $this->writeLine('# ' . $info, $depth * 4); |
|
| 120 | + $info = \str_replace("\n", \sprintf("\n%".$depth * 4.'s# ', ' '), $info); |
|
| 121 | + $this->writeLine('# '.$info, $depth * 4); |
|
| 122 | 122 | } |
| 123 | 123 | $this->writeLine($text, $depth * 4); |
| 124 | 124 | // output defaults |
| 125 | 125 | if ($defaultArray) { |
| 126 | 126 | $this->writeLine(''); |
| 127 | 127 | $message = \count($defaultArray) > 1 ? 'Defaults' : 'Default'; |
| 128 | - $this->writeLine('# ' . $message . ':', $depth * 4 + 4); |
|
| 128 | + $this->writeLine('# '.$message.':', $depth * 4 + 4); |
|
| 129 | 129 | $this->writeArray($defaultArray, $depth + 1); |
| 130 | 130 | } |
| 131 | 131 | if (\is_array($example)) { |
| 132 | 132 | $this->writeLine(''); |
| 133 | 133 | $message = \count($example) > 1 ? 'Examples' : 'Example'; |
| 134 | - $this->writeLine('# ' . $message . ':', $depth * 4 + 4); |
|
| 134 | + $this->writeLine('# '.$message.':', $depth * 4 + 4); |
|
| 135 | 135 | $this->writeArray($example, $depth + 1); |
| 136 | 136 | } |
| 137 | 137 | if ($children) { |
| 138 | 138 | foreach ($children as $childNode) { |
| 139 | - $this->writeNode($childNode, $node, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute()); |
|
| 139 | + $this->writeNode($childNode, $node, $depth + 1, $node instanceof PrototypedArrayNode && ! $node->getKeyAttribute()); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | private function writeLine($text, $indent = 0) |
| 150 | 150 | { |
| 151 | 151 | $indent = \strlen($text) + $indent; |
| 152 | - $format = '%' . $indent . 's'; |
|
| 153 | - $this->reference .= \sprintf($format, $text) . "\n"; |
|
| 152 | + $format = '%'.$indent.'s'; |
|
| 153 | + $this->reference .= \sprintf($format, $text)."\n"; |
|
| 154 | 154 | } |
| 155 | 155 | private function writeArray(array $array, $depth) |
| 156 | 156 | { |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | $val = $value; |
| 163 | 163 | } |
| 164 | 164 | if ($isIndexed) { |
| 165 | - $this->writeLine('- ' . $val, $depth * 4); |
|
| 165 | + $this->writeLine('- '.$val, $depth * 4); |
|
| 166 | 166 | } else { |
| 167 | - $this->writeLine(\sprintf('%-20s %s', $key . ':', $val), $depth * 4); |
|
| 167 | + $this->writeLine(\sprintf('%-20s %s', $key.':', $val), $depth * 4); |
|
| 168 | 168 | } |
| 169 | 169 | if (\is_array($value)) { |
| 170 | 170 | $this->writeArray($value, $depth + 1); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $prototype = $node->getPrototype(); |
| 180 | 180 | $key = $node->getKeyAttribute(); |
| 181 | 181 | // Do not expand prototype if it isn't an array node nor uses attribute as key |
| 182 | - if (!$key && !$prototype instanceof ArrayNode) { |
|
| 182 | + if ( ! $key && ! $prototype instanceof ArrayNode) { |
|
| 183 | 183 | return $node->getChildren(); |
| 184 | 184 | } |
| 185 | 185 | if ($prototype instanceof ArrayNode) { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | $info = 'Prototype'; |
| 199 | 199 | if (null !== $prototype->getInfo()) { |
| 200 | - $info .= ': ' . $prototype->getInfo(); |
|
| 200 | + $info .= ': '.$prototype->getInfo(); |
|
| 201 | 201 | } |
| 202 | 202 | $keyNode->setInfo($info); |
| 203 | 203 | return [$key => $keyNode]; |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | private function writeNode(NodeInterface $node, $depth = 0, $root = \false, $namespace = null) |
| 44 | 44 | { |
| 45 | 45 | $rootName = $root ? 'config' : $node->getName(); |
| 46 | - $rootNamespace = $namespace ?: ($root ? 'http://example.org/schema/dic/' . $node->getName() : null); |
|
| 46 | + $rootNamespace = $namespace ?: ($root ? 'http://example.org/schema/dic/'.$node->getName() : null); |
|
| 47 | 47 | // xml remapping |
| 48 | 48 | if ($node->getParent()) { |
| 49 | - $remapping = \array_filter($node->getParent()->getXmlRemappings(), function ($mapping) use($rootName) { |
|
| 49 | + $remapping = \array_filter($node->getParent()->getXmlRemappings(), function($mapping) use($rootName) { |
|
| 50 | 50 | return $rootName === $mapping[1]; |
| 51 | 51 | }); |
| 52 | 52 | if (\count($remapping)) { |
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | $rootComments[] = $rootInfo; |
| 67 | 67 | } |
| 68 | 68 | if ($rootNamespace) { |
| 69 | - $rootComments[] = 'Namespace: ' . $rootNamespace; |
|
| 69 | + $rootComments[] = 'Namespace: '.$rootNamespace; |
|
| 70 | 70 | } |
| 71 | 71 | // render prototyped nodes |
| 72 | 72 | if ($node instanceof PrototypedArrayNode) { |
| 73 | 73 | $prototype = $node->getPrototype(); |
| 74 | 74 | $info = 'prototype'; |
| 75 | 75 | if (null !== $prototype->getInfo()) { |
| 76 | - $info .= ': ' . $prototype->getInfo(); |
|
| 76 | + $info .= ': '.$prototype->getInfo(); |
|
| 77 | 77 | } |
| 78 | 78 | \array_unshift($rootComments, $info); |
| 79 | 79 | if ($key = $node->getKeyAttribute()) { |
| 80 | - $rootAttributes[$key] = \str_replace('-', ' ', $rootName) . ' ' . $key; |
|
| 80 | + $rootAttributes[$key] = \str_replace('-', ' ', $rootName).' '.$key; |
|
| 81 | 81 | } |
| 82 | 82 | if ($prototype instanceof PrototypedArrayNode) { |
| 83 | 83 | $prototype->setName($key); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | // get attributes and elements |
| 112 | 112 | foreach ($children as $child) { |
| 113 | - if (!$child instanceof ArrayNode) { |
|
| 113 | + if ( ! $child instanceof ArrayNode) { |
|
| 114 | 114 | // get attributes |
| 115 | 115 | // metadata |
| 116 | 116 | $name = \str_replace('_', '-', $child->getName()); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $comments[] = $info; |
| 123 | 123 | } |
| 124 | 124 | if ($example = $child->getExample()) { |
| 125 | - $comments[] = 'Example: ' . $example; |
|
| 125 | + $comments[] = 'Example: '.$example; |
|
| 126 | 126 | } |
| 127 | 127 | if ($child->isRequired()) { |
| 128 | 128 | $comments[] = 'Required'; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $comments[] = \sprintf('Deprecated (%s)', $child->getDeprecationMessage($child->getName(), $node->getPath())); |
| 132 | 132 | } |
| 133 | 133 | if ($child instanceof EnumNode) { |
| 134 | - $comments[] = 'One of ' . \implode('; ', \array_map('json_encode', $child->getValues())); |
|
| 134 | + $comments[] = 'One of '.\implode('; ', \array_map('json_encode', $child->getValues())); |
|
| 135 | 135 | } |
| 136 | 136 | if (\count($comments)) { |
| 137 | 137 | $rootAttributeComments[$name] = \implode(";\n", $comments); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // root node comment |
| 153 | 153 | if (\count($rootComments)) { |
| 154 | 154 | foreach ($rootComments as $comment) { |
| 155 | - $this->writeLine('<!-- ' . $comment . ' -->', $depth); |
|
| 155 | + $this->writeLine('<!-- '.$comment.' -->', $depth); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | // attribute comments |
@@ -161,27 +161,27 @@ discard block |
||
| 161 | 161 | $commentDepth = $depth + 4 + \strlen($attrName) + 2; |
| 162 | 162 | $commentLines = \explode("\n", $comment); |
| 163 | 163 | $multiline = \count($commentLines) > 1; |
| 164 | - $comment = \implode(\PHP_EOL . \str_repeat(' ', $commentDepth), $commentLines); |
|
| 164 | + $comment = \implode(\PHP_EOL.\str_repeat(' ', $commentDepth), $commentLines); |
|
| 165 | 165 | if ($multiline) { |
| 166 | 166 | $this->writeLine('<!--', $depth); |
| 167 | - $this->writeLine($attrName . ': ' . $comment, $depth + 4); |
|
| 167 | + $this->writeLine($attrName.': '.$comment, $depth + 4); |
|
| 168 | 168 | $this->writeLine('-->', $depth); |
| 169 | 169 | } else { |
| 170 | - $this->writeLine('<!-- ' . $attrName . ': ' . $comment . ' -->', $depth); |
|
| 170 | + $this->writeLine('<!-- '.$attrName.': '.$comment.' -->', $depth); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | // render start tag + attributes |
| 175 | 175 | $rootIsVariablePrototype = isset($prototypeValue); |
| 176 | - $rootIsEmptyTag = 0 === \count($rootChildren) && !$rootIsVariablePrototype; |
|
| 177 | - $rootOpenTag = '<' . $rootName; |
|
| 176 | + $rootIsEmptyTag = 0 === \count($rootChildren) && ! $rootIsVariablePrototype; |
|
| 177 | + $rootOpenTag = '<'.$rootName; |
|
| 178 | 178 | if (1 >= ($attributesCount = \count($rootAttributes))) { |
| 179 | 179 | if (1 === $attributesCount) { |
| 180 | 180 | $rootOpenTag .= \sprintf(' %s="%s"', \current(\array_keys($rootAttributes)), $this->writeValue(\current($rootAttributes))); |
| 181 | 181 | } |
| 182 | 182 | $rootOpenTag .= $rootIsEmptyTag ? ' />' : '>'; |
| 183 | 183 | if ($rootIsVariablePrototype) { |
| 184 | - $rootOpenTag .= $prototypeValue . '</' . $rootName . '>'; |
|
| 184 | + $rootOpenTag .= $prototypeValue.'</'.$rootName.'>'; |
|
| 185 | 185 | } |
| 186 | 186 | $this->writeLine($rootOpenTag, $depth); |
| 187 | 187 | } else { |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | if ($attributesCount === $i++) { |
| 194 | 194 | $this->writeLine($rootIsEmptyTag ? '/>' : '>', $depth); |
| 195 | 195 | if ($rootIsVariablePrototype) { |
| 196 | - $rootOpenTag .= $prototypeValue . '</' . $rootName . '>'; |
|
| 196 | + $rootOpenTag .= $prototypeValue.'</'.$rootName.'>'; |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | $this->writeNode($child, $depth + 4); |
| 205 | 205 | } |
| 206 | 206 | // render end tag |
| 207 | - if (!$rootIsEmptyTag && !$rootIsVariablePrototype) { |
|
| 207 | + if ( ! $rootIsEmptyTag && ! $rootIsVariablePrototype) { |
|
| 208 | 208 | $this->writeLine(''); |
| 209 | - $rootEndTag = '</' . $rootName . '>'; |
|
| 209 | + $rootEndTag = '</'.$rootName.'>'; |
|
| 210 | 210 | $this->writeLine($rootEndTag, $depth); |
| 211 | 211 | } |
| 212 | 212 | } |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | private function writeLine($text, $indent = 0) |
| 220 | 220 | { |
| 221 | 221 | $indent = \strlen($text) + $indent; |
| 222 | - $format = '%' . $indent . 's'; |
|
| 223 | - $this->reference .= \sprintf($format, $text) . \PHP_EOL; |
|
| 222 | + $format = '%'.$indent.'s'; |
|
| 223 | + $this->reference .= \sprintf($format, $text).\PHP_EOL; |
|
| 224 | 224 | } |
| 225 | 225 | /** |
| 226 | 226 | * Renders the string conversion of the value. |
@@ -58,18 +58,18 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function isFresh() |
| 60 | 60 | { |
| 61 | - if (!\is_file($this->file)) { |
|
| 61 | + if ( ! \is_file($this->file)) { |
|
| 62 | 62 | return \false; |
| 63 | 63 | } |
| 64 | - if ($this->resourceCheckers instanceof \Traversable && !$this->resourceCheckers instanceof \Countable) { |
|
| 64 | + if ($this->resourceCheckers instanceof \Traversable && ! $this->resourceCheckers instanceof \Countable) { |
|
| 65 | 65 | $this->resourceCheckers = \iterator_to_array($this->resourceCheckers); |
| 66 | 66 | } |
| 67 | - if (!\count($this->resourceCheckers)) { |
|
| 67 | + if ( ! \count($this->resourceCheckers)) { |
|
| 68 | 68 | return \true; |
| 69 | 69 | // shortcut - if we don't have any checkers we don't need to bother with the meta file at all |
| 70 | 70 | } |
| 71 | 71 | $metadata = $this->getMetaFile(); |
| 72 | - if (!\is_file($metadata)) { |
|
| 72 | + if ( ! \is_file($metadata)) { |
|
| 73 | 73 | return \false; |
| 74 | 74 | } |
| 75 | 75 | $meta = $this->safelyUnserialize($metadata); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | foreach ($meta as $resource) { |
| 81 | 81 | /* @var ResourceInterface $resource */ |
| 82 | 82 | foreach ($this->resourceCheckers as $checker) { |
| 83 | - if (!$checker->supports($resource)) { |
|
| 83 | + if ( ! $checker->supports($resource)) { |
|
| 84 | 84 | continue; |
| 85 | 85 | // next checker |
| 86 | 86 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | private function getMetaFile() |
| 135 | 135 | { |
| 136 | - return $this->file . '.meta'; |
|
| 136 | + return $this->file.'.meta'; |
|
| 137 | 137 | } |
| 138 | 138 | private function safelyUnserialize($file) |
| 139 | 139 | { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $content = \file_get_contents($file); |
| 143 | 143 | $signalingException = new \UnexpectedValueException(); |
| 144 | 144 | $prevUnserializeHandler = \ini_set('unserialize_callback_func', ''); |
| 145 | - $prevErrorHandler = \set_error_handler(function ($type, $msg, $file, $line, $context = []) use(&$prevErrorHandler, $signalingException) { |
|
| 145 | + $prevErrorHandler = \set_error_handler(function($type, $msg, $file, $line, $context = []) use(&$prevErrorHandler, $signalingException) { |
|
| 146 | 146 | if (__FILE__ === $file) { |
| 147 | 147 | throw $signalingException; |
| 148 | 148 | } |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $i = \strpos($name, ':'); |
| 39 | 39 | if ('file' === $prefix) { |
| 40 | - if (!\is_scalar($file = $getEnv($name))) { |
|
| 40 | + if ( ! \is_scalar($file = $getEnv($name))) { |
|
| 41 | 41 | throw new RuntimeException(\sprintf('Invalid file name: env var "%s" is non-scalar.', $name)); |
| 42 | 42 | } |
| 43 | - if (!\file_exists($file)) { |
|
| 43 | + if ( ! \file_exists($file)) { |
|
| 44 | 44 | throw new RuntimeException(\sprintf('Env "file:%s" not found: "%s" does not exist.', $name, $file)); |
| 45 | 45 | } |
| 46 | 46 | return \file_get_contents($file); |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | $env = $_SERVER[$name]; |
| 56 | 56 | } elseif (\false === ($env = \getenv($name)) || null === $env) { |
| 57 | 57 | // null is a possible value because of thread safety issues |
| 58 | - if (!$this->container->hasParameter("env({$name})")) { |
|
| 58 | + if ( ! $this->container->hasParameter("env({$name})")) { |
|
| 59 | 59 | throw new EnvNotFoundException($name); |
| 60 | 60 | } |
| 61 | 61 | if (null === ($env = $this->container->getParameter("env({$name})"))) { |
| 62 | 62 | return null; |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | - if (!\is_scalar($env)) { |
|
| 65 | + if ( ! \is_scalar($env)) { |
|
| 66 | 66 | throw new RuntimeException(\sprintf('Non-scalar env var "%s" cannot be cast to "%s".', $name, $prefix)); |
| 67 | 67 | } |
| 68 | 68 | if ('string' === $prefix) { |
@@ -72,19 +72,19 @@ discard block |
||
| 72 | 72 | return (bool) self::phpize($env); |
| 73 | 73 | } |
| 74 | 74 | if ('int' === $prefix) { |
| 75 | - if (!\is_numeric($env = self::phpize($env))) { |
|
| 75 | + if ( ! \is_numeric($env = self::phpize($env))) { |
|
| 76 | 76 | throw new RuntimeException(\sprintf('Non-numeric env var "%s" cannot be cast to int.', $name)); |
| 77 | 77 | } |
| 78 | 78 | return (int) $env; |
| 79 | 79 | } |
| 80 | 80 | if ('float' === $prefix) { |
| 81 | - if (!\is_numeric($env = self::phpize($env))) { |
|
| 81 | + if ( ! \is_numeric($env = self::phpize($env))) { |
|
| 82 | 82 | throw new RuntimeException(\sprintf('Non-numeric env var "%s" cannot be cast to float.', $name)); |
| 83 | 83 | } |
| 84 | 84 | return (float) $env; |
| 85 | 85 | } |
| 86 | 86 | if ('const' === $prefix) { |
| 87 | - if (!\defined($env)) { |
|
| 87 | + if ( ! \defined($env)) { |
|
| 88 | 88 | throw new RuntimeException(\sprintf('Env var "%s" maps to undefined constant "%s".', $name, $env)); |
| 89 | 89 | } |
| 90 | 90 | return \constant($env); |
@@ -95,20 +95,20 @@ discard block |
||
| 95 | 95 | if ('json' === $prefix) { |
| 96 | 96 | $env = \json_decode($env, \true); |
| 97 | 97 | if (\JSON_ERROR_NONE !== \json_last_error()) { |
| 98 | - throw new RuntimeException(\sprintf('Invalid JSON in env var "%s": ', $name) . \json_last_error_msg()); |
|
| 98 | + throw new RuntimeException(\sprintf('Invalid JSON in env var "%s": ', $name).\json_last_error_msg()); |
|
| 99 | 99 | } |
| 100 | - if (!\is_array($env)) { |
|
| 100 | + if ( ! \is_array($env)) { |
|
| 101 | 101 | throw new RuntimeException(\sprintf('Invalid JSON env var "%s": array expected, "%s" given.', $name, \gettype($env))); |
| 102 | 102 | } |
| 103 | 103 | return $env; |
| 104 | 104 | } |
| 105 | 105 | if ('resolve' === $prefix) { |
| 106 | - return \preg_replace_callback('/%%|%([^%\\s]+)%/', function ($match) use($name) { |
|
| 107 | - if (!isset($match[1])) { |
|
| 106 | + return \preg_replace_callback('/%%|%([^%\\s]+)%/', function($match) use($name) { |
|
| 107 | + if ( ! isset($match[1])) { |
|
| 108 | 108 | return '%'; |
| 109 | 109 | } |
| 110 | 110 | $value = $this->container->getParameter($match[1]); |
| 111 | - if (!\is_scalar($value)) { |
|
| 111 | + if ( ! \is_scalar($value)) { |
|
| 112 | 112 | throw new RuntimeException(\sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1], $name, \gettype($value))); |
| 113 | 113 | } |
| 114 | 114 | return $value; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | private static function phpize($value) |
| 120 | 120 | { |
| 121 | - if (!\class_exists(XmlUtils::class)) { |
|
| 121 | + if ( ! \class_exists(XmlUtils::class)) { |
|
| 122 | 122 | throw new RuntimeException('The Symfony Config component is required to cast env vars to "bool", "int" or "float".'); |
| 123 | 123 | } |
| 124 | 124 | return XmlUtils::phpize($value); |
@@ -55,9 +55,9 @@ |
||
| 55 | 55 | } else { |
| 56 | 56 | $this->message .= ' Did you mean one of these: "'; |
| 57 | 57 | } |
| 58 | - $this->message .= \implode('", "', $this->alternatives) . '"?'; |
|
| 58 | + $this->message .= \implode('", "', $this->alternatives).'"?'; |
|
| 59 | 59 | } elseif (null !== $this->nonNestedAlternative) { |
| 60 | - $this->message .= ' You cannot access nested array items, do you want to inject "' . $this->nonNestedAlternative . '" instead?'; |
|
| 60 | + $this->message .= ' You cannot access nested array items, do you want to inject "'.$this->nonNestedAlternative.'" instead?'; |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | public function getKey() |