@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private function read(string $file): string |
108 | 108 | { |
109 | - if (! \is_readable($file)) { |
|
110 | - throw new \InvalidArgumentException('Unable to read file "' . $file . '"'); |
|
109 | + if (!\is_readable($file)){ |
|
110 | + throw new \InvalidArgumentException('Unable to read file "'.$file.'"'); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return \file_get_contents($file); |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | { |
125 | 125 | $eval = new ConstExprEvaluator($this->evaluator($file, $context)); |
126 | 126 | |
127 | - foreach ($groups as $group) { |
|
128 | - foreach ($group->attrs as $attr) { |
|
127 | + foreach ($groups as $group){ |
|
128 | + foreach ($group->attrs as $attr){ |
|
129 | 129 | $arguments = $this->parseAttributeArguments($attr, $file, $eval); |
130 | 130 | |
131 | 131 | yield new AttributePrototype($attr->name->toString(), $arguments); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | private function evaluator(string $file, array $context): \Closure |
142 | 142 | { |
143 | 143 | return static function (Expr $expr) use ($file, $context) { |
144 | - switch (\get_class($expr)) { |
|
144 | + switch (\get_class($expr)){ |
|
145 | 145 | case Scalar\MagicConst\File::class: |
146 | 146 | return $file; |
147 | 147 | |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | $namespace = $context[self::CTX_NAMESPACE] ?? ''; |
156 | 156 | $function = $context[self::CTX_FUNCTION] ?? ''; |
157 | 157 | |
158 | - return \ltrim($namespace . '\\' . $function, '\\'); |
|
158 | + return \ltrim($namespace.'\\'.$function, '\\'); |
|
159 | 159 | |
160 | 160 | case Expr\ClassConstFetch::class: |
161 | - $constant = $expr->class->toString() . '::' . $expr->name->toString(); |
|
161 | + $constant = $expr->class->toString().'::'.$expr->name->toString(); |
|
162 | 162 | |
163 | - if (! \defined($constant)) { |
|
163 | + if (!\defined($constant)){ |
|
164 | 164 | $exception = new \ParseError(\sprintf(self::ERROR_BAD_CONSTANT, $constant)); |
165 | 165 | throw Exception::withLocation($exception, $file, $expr->getStartLine()); |
166 | 166 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | return \constant($constant); |
169 | 169 | } |
170 | 170 | |
171 | - if ($expr instanceof Scalar\MagicConst) { |
|
171 | + if ($expr instanceof Scalar\MagicConst){ |
|
172 | 172 | return $context[$expr->getName()] ?? ''; |
173 | 173 | } |
174 | 174 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | $hasNamedArguments = false; |
191 | 191 | $arguments = []; |
192 | 192 | |
193 | - foreach ($attr->args as $argument) { |
|
193 | + foreach ($attr->args as $argument){ |
|
194 | 194 | $value = $eval->evaluateDirectly($argument->value); |
195 | 195 | |
196 | - if ($argument->name === null) { |
|
196 | + if ($argument->name === null){ |
|
197 | 197 | $arguments[] = $value; |
198 | 198 | |
199 | - if ($hasNamedArguments) { |
|
199 | + if ($hasNamedArguments){ |
|
200 | 200 | $exception = new \ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER); |
201 | 201 | throw Exception::withLocation($exception, $file, $argument->getStartLine()); |
202 | 202 | } |
@@ -106,7 +106,8 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private function read(string $file): string |
108 | 108 | { |
109 | - if (! \is_readable($file)) { |
|
109 | + if (! \is_readable($file)) |
|
110 | + { |
|
110 | 111 | throw new \InvalidArgumentException('Unable to read file "' . $file . '"'); |
111 | 112 | } |
112 | 113 | |
@@ -124,8 +125,10 @@ discard block |
||
124 | 125 | { |
125 | 126 | $eval = new ConstExprEvaluator($this->evaluator($file, $context)); |
126 | 127 | |
127 | - foreach ($groups as $group) { |
|
128 | - foreach ($group->attrs as $attr) { |
|
128 | + foreach ($groups as $group) |
|
129 | + { |
|
130 | + foreach ($group->attrs as $attr) |
|
131 | + { |
|
129 | 132 | $arguments = $this->parseAttributeArguments($attr, $file, $eval); |
130 | 133 | |
131 | 134 | yield new AttributePrototype($attr->name->toString(), $arguments); |
@@ -140,8 +143,10 @@ discard block |
||
140 | 143 | */ |
141 | 144 | private function evaluator(string $file, array $context): \Closure |
142 | 145 | { |
143 | - return static function (Expr $expr) use ($file, $context) { |
|
144 | - switch (\get_class($expr)) { |
|
146 | + return static function (Expr $expr) use ($file, $context) |
|
147 | + { |
|
148 | + switch (\get_class($expr)) |
|
149 | + { |
|
145 | 150 | case Scalar\MagicConst\File::class: |
146 | 151 | return $file; |
147 | 152 | |
@@ -160,7 +165,8 @@ discard block |
||
160 | 165 | case Expr\ClassConstFetch::class: |
161 | 166 | $constant = $expr->class->toString() . '::' . $expr->name->toString(); |
162 | 167 | |
163 | - if (! \defined($constant)) { |
|
168 | + if (! \defined($constant)) |
|
169 | + { |
|
164 | 170 | $exception = new \ParseError(\sprintf(self::ERROR_BAD_CONSTANT, $constant)); |
165 | 171 | throw Exception::withLocation($exception, $file, $expr->getStartLine()); |
166 | 172 | } |
@@ -168,7 +174,8 @@ discard block |
||
168 | 174 | return \constant($constant); |
169 | 175 | } |
170 | 176 | |
171 | - if ($expr instanceof Scalar\MagicConst) { |
|
177 | + if ($expr instanceof Scalar\MagicConst) |
|
178 | + { |
|
172 | 179 | return $context[$expr->getName()] ?? ''; |
173 | 180 | } |
174 | 181 | |
@@ -190,13 +197,16 @@ discard block |
||
190 | 197 | $hasNamedArguments = false; |
191 | 198 | $arguments = []; |
192 | 199 | |
193 | - foreach ($attr->args as $argument) { |
|
200 | + foreach ($attr->args as $argument) |
|
201 | + { |
|
194 | 202 | $value = $eval->evaluateDirectly($argument->value); |
195 | 203 | |
196 | - if ($argument->name === null) { |
|
204 | + if ($argument->name === null) |
|
205 | + { |
|
197 | 206 | $arguments[] = $value; |
198 | 207 | |
199 | - if ($hasNamedArguments) { |
|
208 | + if ($hasNamedArguments) |
|
209 | + { |
|
200 | 210 | $exception = new \ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER); |
201 | 211 | throw Exception::withLocation($exception, $file, $argument->getStartLine()); |
202 | 212 | } |