@@ -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 | } |