Passed
Push — master ( 46bff1...2fa4c6 )
by Kirill
04:03
created
src/Attributes/src/Internal/AttributeParser.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $eval = new ConstExprEvaluator($this->evaluator($file, $context));
101 101
 
102
-        foreach ($groups as $group) {
103
-            foreach ($group->attrs as $attr) {
102
+        foreach ($groups as $group){
103
+            foreach ($group->attrs as $attr){
104 104
                 $arguments = $this->parseAttributeArguments($attr, $file, $eval);
105 105
 
106 106
                 yield new AttributePrototype($attr->name->toString(), $arguments);
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function read(string $file): string
126 126
     {
127
-        if (!\is_readable($file)) {
128
-            throw new \InvalidArgumentException('Unable to read file "' . $file . '"');
127
+        if (!\is_readable($file)){
128
+            throw new \InvalidArgumentException('Unable to read file "'.$file.'"');
129 129
         }
130 130
 
131 131
         return \file_get_contents($file);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     private function evaluator(string $file, array $context): \Closure
140 140
     {
141 141
         return static function (Expr $expr) use ($file, $context) {
142
-            switch (\get_class($expr)) {
142
+            switch (\get_class($expr)){
143 143
                 case Scalar\MagicConst\File::class:
144 144
                     return $file;
145 145
 
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
                     $namespace = $context[self::CTX_NAMESPACE] ?? '';
154 154
                     $function = $context[self::CTX_FUNCTION] ?? '';
155 155
 
156
-                    return \ltrim($namespace . '\\' . $function, '\\');
156
+                    return \ltrim($namespace.'\\'.$function, '\\');
157 157
             }
158 158
 
159
-            if ($expr instanceof Scalar\MagicConst) {
159
+            if ($expr instanceof Scalar\MagicConst){
160 160
                 return $context[$expr->getName()] ?? '';
161 161
             }
162 162
 
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
         $hasNamedArguments = false;
179 179
         $arguments = [];
180 180
 
181
-        foreach ($attr->args as $argument) {
181
+        foreach ($attr->args as $argument){
182 182
             $value = $eval->evaluateDirectly($argument->value);
183 183
 
184
-            if ($argument->name === null) {
184
+            if ($argument->name === null){
185 185
                 $arguments[] = $value;
186 186
 
187
-                if ($hasNamedArguments) {
187
+                if ($hasNamedArguments){
188 188
                     $exception = new \ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER);
189 189
                     throw Exception::withLocation($exception, $file, $argument->getStartLine());
190 190
                 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -99,8 +99,10 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $eval = new ConstExprEvaluator($this->evaluator($file, $context));
101 101
 
102
-        foreach ($groups as $group) {
103
-            foreach ($group->attrs as $attr) {
102
+        foreach ($groups as $group)
103
+        {
104
+            foreach ($group->attrs as $attr)
105
+            {
104 106
                 $arguments = $this->parseAttributeArguments($attr, $file, $eval);
105 107
 
106 108
                 yield new AttributePrototype($attr->name->toString(), $arguments);
@@ -124,7 +126,8 @@  discard block
 block discarded – undo
124 126
      */
125 127
     private function read(string $file): string
126 128
     {
127
-        if (!\is_readable($file)) {
129
+        if (!\is_readable($file))
130
+        {
128 131
             throw new \InvalidArgumentException('Unable to read file "' . $file . '"');
129 132
         }
130 133
 
@@ -138,8 +141,10 @@  discard block
 block discarded – undo
138 141
      */
139 142
     private function evaluator(string $file, array $context): \Closure
140 143
     {
141
-        return static function (Expr $expr) use ($file, $context) {
142
-            switch (\get_class($expr)) {
144
+        return static function (Expr $expr) use ($file, $context)
145
+        {
146
+            switch (\get_class($expr))
147
+            {
143 148
                 case Scalar\MagicConst\File::class:
144 149
                     return $file;
145 150
 
@@ -156,7 +161,8 @@  discard block
 block discarded – undo
156 161
                     return \ltrim($namespace . '\\' . $function, '\\');
157 162
             }
158 163
 
159
-            if ($expr instanceof Scalar\MagicConst) {
164
+            if ($expr instanceof Scalar\MagicConst)
165
+            {
160 166
                 return $context[$expr->getName()] ?? '';
161 167
             }
162 168
 
@@ -178,13 +184,16 @@  discard block
 block discarded – undo
178 184
         $hasNamedArguments = false;
179 185
         $arguments = [];
180 186
 
181
-        foreach ($attr->args as $argument) {
187
+        foreach ($attr->args as $argument)
188
+        {
182 189
             $value = $eval->evaluateDirectly($argument->value);
183 190
 
184
-            if ($argument->name === null) {
191
+            if ($argument->name === null)
192
+            {
185 193
                 $arguments[] = $value;
186 194
 
187
-                if ($hasNamedArguments) {
195
+                if ($hasNamedArguments)
196
+                {
188 197
                     $exception = new \ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER);
189 198
                     throw Exception::withLocation($exception, $file, $argument->getStartLine());
190 199
                 }
Please login to merge, or discard this patch.