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