@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | { |
119 | 119 | $eval = new ConstExprEvaluator($this->evaluator($file, $context)); |
120 | 120 | |
121 | - foreach ($groups as $group) { |
|
122 | - foreach ($group->attrs as $attr) { |
|
121 | + foreach ($groups as $group){ |
|
122 | + foreach ($group->attrs as $attr){ |
|
123 | 123 | $arguments = $this->parseAttributeArguments($attr, $file, $eval); |
124 | 124 | |
125 | 125 | yield new AttributePrototype($attr->name->toString(), $arguments); |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | */ |
144 | 144 | private function read(string $file): string |
145 | 145 | { |
146 | - if (!\is_readable($file)) { |
|
147 | - throw new \InvalidArgumentException('Unable to read file "' . $file . '"'); |
|
146 | + if (!\is_readable($file)){ |
|
147 | + throw new \InvalidArgumentException('Unable to read file "'.$file.'"'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | return \file_get_contents($file); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | private function evaluator(string $file, array $context): \Closure |
159 | 159 | { |
160 | 160 | return static function (Expr $expr) use ($file, $context) { |
161 | - switch (\get_class($expr)) { |
|
161 | + switch (\get_class($expr)){ |
|
162 | 162 | case Scalar\MagicConst\File::class: |
163 | 163 | return $file; |
164 | 164 | |
@@ -172,19 +172,19 @@ discard block |
||
172 | 172 | $namespace = $context[self::CTX_NAMESPACE] ?? ''; |
173 | 173 | $function = $context[self::CTX_FUNCTION] ?? ''; |
174 | 174 | |
175 | - return \ltrim($namespace . '\\' . $function, '\\'); |
|
175 | + return \ltrim($namespace.'\\'.$function, '\\'); |
|
176 | 176 | |
177 | 177 | case Expr\ClassConstFetch::class: |
178 | 178 | $constant = $expr->name->toString(); |
179 | 179 | $class = $expr->class->toString(); |
180 | 180 | |
181 | - if (\strtolower($constant) === 'class') { |
|
181 | + if (\strtolower($constant) === 'class'){ |
|
182 | 182 | return $class; |
183 | 183 | } |
184 | 184 | |
185 | - $definition = $class . '::' . $constant; |
|
185 | + $definition = $class.'::'.$constant; |
|
186 | 186 | |
187 | - if (!\defined($definition)) { |
|
187 | + if (!\defined($definition)){ |
|
188 | 188 | $exception = new \ParseError(\sprintf(self::ERROR_BAD_CONSTANT, $definition)); |
189 | 189 | throw Exception::withLocation($exception, $file, $expr->getStartLine()); |
190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | return \constant($definition); |
193 | 193 | } |
194 | 194 | |
195 | - if ($expr instanceof Scalar\MagicConst) { |
|
195 | + if ($expr instanceof Scalar\MagicConst){ |
|
196 | 196 | return $context[$expr->getName()] ?? ''; |
197 | 197 | } |
198 | 198 | |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | $hasNamedArguments = false; |
215 | 215 | $arguments = []; |
216 | 216 | |
217 | - foreach ($attr->args as $argument) { |
|
217 | + foreach ($attr->args as $argument){ |
|
218 | 218 | $value = $eval->evaluateDirectly($argument->value); |
219 | 219 | |
220 | - if ($argument->name === null) { |
|
220 | + if ($argument->name === null){ |
|
221 | 221 | $arguments[] = $value; |
222 | 222 | |
223 | - if ($hasNamedArguments) { |
|
223 | + if ($hasNamedArguments){ |
|
224 | 224 | $exception = new \ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER); |
225 | 225 | throw Exception::withLocation($exception, $file, $argument->getStartLine()); |
226 | 226 | } |
@@ -118,8 +118,10 @@ discard block |
||
118 | 118 | { |
119 | 119 | $eval = new ConstExprEvaluator($this->evaluator($file, $context)); |
120 | 120 | |
121 | - foreach ($groups as $group) { |
|
122 | - foreach ($group->attrs as $attr) { |
|
121 | + foreach ($groups as $group) |
|
122 | + { |
|
123 | + foreach ($group->attrs as $attr) |
|
124 | + { |
|
123 | 125 | $arguments = $this->parseAttributeArguments($attr, $file, $eval); |
124 | 126 | |
125 | 127 | yield new AttributePrototype($attr->name->toString(), $arguments); |
@@ -143,7 +145,8 @@ discard block |
||
143 | 145 | */ |
144 | 146 | private function read(string $file): string |
145 | 147 | { |
146 | - if (!\is_readable($file)) { |
|
148 | + if (!\is_readable($file)) |
|
149 | + { |
|
147 | 150 | throw new \InvalidArgumentException('Unable to read file "' . $file . '"'); |
148 | 151 | } |
149 | 152 | |
@@ -157,8 +160,10 @@ discard block |
||
157 | 160 | */ |
158 | 161 | private function evaluator(string $file, array $context): \Closure |
159 | 162 | { |
160 | - return static function (Expr $expr) use ($file, $context) { |
|
161 | - switch (\get_class($expr)) { |
|
163 | + return static function (Expr $expr) use ($file, $context) |
|
164 | + { |
|
165 | + switch (\get_class($expr)) |
|
166 | + { |
|
162 | 167 | case Scalar\MagicConst\File::class: |
163 | 168 | return $file; |
164 | 169 | |
@@ -178,13 +183,15 @@ discard block |
||
178 | 183 | $constant = $expr->name->toString(); |
179 | 184 | $class = $expr->class->toString(); |
180 | 185 | |
181 | - if (\strtolower($constant) === 'class') { |
|
186 | + if (\strtolower($constant) === 'class') |
|
187 | + { |
|
182 | 188 | return $class; |
183 | 189 | } |
184 | 190 | |
185 | 191 | $definition = $class . '::' . $constant; |
186 | 192 | |
187 | - if (!\defined($definition)) { |
|
193 | + if (!\defined($definition)) |
|
194 | + { |
|
188 | 195 | $exception = new \ParseError(\sprintf(self::ERROR_BAD_CONSTANT, $definition)); |
189 | 196 | throw Exception::withLocation($exception, $file, $expr->getStartLine()); |
190 | 197 | } |
@@ -192,7 +199,8 @@ discard block |
||
192 | 199 | return \constant($definition); |
193 | 200 | } |
194 | 201 | |
195 | - if ($expr instanceof Scalar\MagicConst) { |
|
202 | + if ($expr instanceof Scalar\MagicConst) |
|
203 | + { |
|
196 | 204 | return $context[$expr->getName()] ?? ''; |
197 | 205 | } |
198 | 206 | |
@@ -214,13 +222,16 @@ discard block |
||
214 | 222 | $hasNamedArguments = false; |
215 | 223 | $arguments = []; |
216 | 224 | |
217 | - foreach ($attr->args as $argument) { |
|
225 | + foreach ($attr->args as $argument) |
|
226 | + { |
|
218 | 227 | $value = $eval->evaluateDirectly($argument->value); |
219 | 228 | |
220 | - if ($argument->name === null) { |
|
229 | + if ($argument->name === null) |
|
230 | + { |
|
221 | 231 | $arguments[] = $value; |
222 | 232 | |
223 | - if ($hasNamedArguments) { |
|
233 | + if ($hasNamedArguments) |
|
234 | + { |
|
224 | 235 | $exception = new \ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER); |
225 | 236 | throw Exception::withLocation($exception, $file, $argument->getStartLine()); |
226 | 237 | } |