Passed
Pull Request — master (#1196)
by Abdul Malik
11:01
created
src/Stempler/src/Compiler/Renderer/DynamicRenderer.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
     public function __construct(
20 20
         private readonly ?DirectiveRendererInterface $directiveRenderer = null,
21 21
         private readonly string $defaultFilter = self::DEFAULT_FILTER
22
-    ) {
22
+    ){
23 23
     }
24 24
 
25 25
     public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool
26 26
     {
27
-        switch (true) {
27
+        switch (true){
28 28
             case $node instanceof Output:
29 29
                 $this->output($result, $node);
30 30
                 return true;
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
      */
42 42
     private function directive(Compiler\Result $source, Directive $directive): void
43 43
     {
44
-        if ($this->directiveRenderer instanceof \Spiral\Stempler\Directive\DirectiveRendererInterface) {
44
+        if ($this->directiveRenderer instanceof \Spiral\Stempler\Directive\DirectiveRendererInterface){
45 45
             $result = $this->directiveRenderer->render($directive);
46
-            if ($result !== null) {
46
+            if ($result !== null){
47 47
                 $source->push($result, $directive->getContext());
48 48
                 return;
49 49
             }
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
 
58 58
     private function output(Compiler\Result $source, Output $output): void
59 59
     {
60
-        if ($output->rawOutput) {
61
-            $source->push(\sprintf('<?php echo %s; ?>', \trim((string) $output->body)), $output->getContext());
60
+        if ($output->rawOutput){
61
+            $source->push(\sprintf('<?php echo %s; ?>', \trim((string)$output->body)), $output->getContext());
62 62
             return;
63 63
         }
64 64
 
65 65
         $filter = $output->filter ?? $this->defaultFilter;
66 66
 
67 67
         $source->push(
68
-            \sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim((string) $output->body)),
68
+            \sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim((string)$output->body)),
69 69
             $output->getContext()
70 70
         );
71 71
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool
26 26
     {
27
-        switch (true) {
27
+        switch (true)
28
+        {
28 29
             case $node instanceof Output:
29 30
                 $this->output($result, $node);
30 31
                 return true;
@@ -41,9 +42,11 @@  discard block
 block discarded – undo
41 42
      */
42 43
     private function directive(Compiler\Result $source, Directive $directive): void
43 44
     {
44
-        if ($this->directiveRenderer instanceof \Spiral\Stempler\Directive\DirectiveRendererInterface) {
45
+        if ($this->directiveRenderer instanceof \Spiral\Stempler\Directive\DirectiveRendererInterface)
46
+        {
45 47
             $result = $this->directiveRenderer->render($directive);
46
-            if ($result !== null) {
48
+            if ($result !== null)
49
+            {
47 50
                 $source->push($result, $directive->getContext());
48 51
                 return;
49 52
             }
@@ -57,7 +60,8 @@  discard block
 block discarded – undo
57 60
 
58 61
     private function output(Compiler\Result $source, Output $output): void
59 62
     {
60
-        if ($output->rawOutput) {
63
+        if ($output->rawOutput)
64
+        {
61 65
             $source->push(\sprintf('<?php echo %s; ?>', \trim((string) $output->body)), $output->getContext());
62 66
             return;
63 67
         }
Please login to merge, or discard this patch.
src/Stempler/src/Compiler/Result.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,22 +24,22 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function withinContext(?Context $ctx, callable $body): void
26 26
     {
27
-        if (!$ctx instanceof \Spiral\Stempler\Parser\Context || $ctx->getPath() === null) {
27
+        if (!$ctx instanceof \Spiral\Stempler\Parser\Context || $ctx->getPath() === null){
28 28
             $body($this);
29 29
             return;
30 30
         }
31 31
 
32
-        try {
32
+        try{
33 33
             $this->parent = Location::fromContext($ctx, $this->parent);
34 34
             $body($this);
35
-        } finally {
35
+        }finally{
36 36
             $this->parent = $this->parent->parent;
37 37
         }
38 38
     }
39 39
 
40 40
     public function push(string $content, ?Context $ctx = null): void
41 41
     {
42
-        if ($ctx instanceof \Spiral\Stempler\Parser\Context && $ctx->getPath() !== null) {
42
+        if ($ctx instanceof \Spiral\Stempler\Parser\Context && $ctx->getPath() !== null){
43 43
             $this->locations[\strlen($this->content)] = Location::fromContext($ctx, $this->parent);
44 44
         }
45 45
 
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
         $paths = [];
60 60
 
61 61
         // We can scan top level only
62
-        foreach ($this->locations as $loc) {
63
-            if (!\in_array($loc->path, $paths, true)) {
62
+        foreach ($this->locations as $loc){
63
+            if (!\in_array($loc->path, $paths, true)){
64 64
                 $paths[] = $loc->path;
65 65
             }
66 66
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     {
76 76
         $locations = [];
77 77
 
78
-        foreach ($this->locations as $offset => $location) {
78
+        foreach ($this->locations as $offset => $location){
79 79
             $locations[$offset] = $location;
80 80
         }
81 81
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,22 +24,27 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function withinContext(?Context $ctx, callable $body): void
26 26
     {
27
-        if (!$ctx instanceof \Spiral\Stempler\Parser\Context || $ctx->getPath() === null) {
27
+        if (!$ctx instanceof \Spiral\Stempler\Parser\Context || $ctx->getPath() === null)
28
+        {
28 29
             $body($this);
29 30
             return;
30 31
         }
31 32
 
32
-        try {
33
+        try
34
+        {
33 35
             $this->parent = Location::fromContext($ctx, $this->parent);
34 36
             $body($this);
35
-        } finally {
37
+        }
38
+        finally
39
+        {
36 40
             $this->parent = $this->parent->parent;
37 41
         }
38 42
     }
39 43
 
40 44
     public function push(string $content, ?Context $ctx = null): void
41 45
     {
42
-        if ($ctx instanceof \Spiral\Stempler\Parser\Context && $ctx->getPath() !== null) {
46
+        if ($ctx instanceof \Spiral\Stempler\Parser\Context && $ctx->getPath() !== null)
47
+        {
43 48
             $this->locations[\strlen($this->content)] = Location::fromContext($ctx, $this->parent);
44 49
         }
45 50
 
@@ -59,8 +64,10 @@  discard block
 block discarded – undo
59 64
         $paths = [];
60 65
 
61 66
         // We can scan top level only
62
-        foreach ($this->locations as $loc) {
63
-            if (!\in_array($loc->path, $paths, true)) {
67
+        foreach ($this->locations as $loc)
68
+        {
69
+            if (!\in_array($loc->path, $paths, true))
70
+            {
64 71
                 $paths[] = $loc->path;
65 72
             }
66 73
         }
@@ -75,7 +82,8 @@  discard block
 block discarded – undo
75 82
     {
76 83
         $locations = [];
77 84
 
78
-        foreach ($this->locations as $offset => $location) {
85
+        foreach ($this->locations as $offset => $location)
86
+        {
79 87
             $locations[$offset] = $location;
80 88
         }
81 89
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/DynamicGrammar.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
     public function __construct(
48 48
         private readonly ?DirectiveRendererInterface $directiveRenderer = null
49
-    ) {
49
+    ){
50 50
         $this->echo = new BracesGrammar(
51 51
             '{{',
52 52
             '}}',
@@ -67,33 +67,33 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function parse(Buffer $src): \Generator
69 69
     {
70
-        while ($n = $src->next()) {
71
-            if (!$n instanceof Byte) {
70
+        while ($n = $src->next()){
71
+            if (!$n instanceof Byte){
72 72
                 yield $n;
73 73
                 continue;
74 74
             }
75 75
 
76
-            if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR) {
76
+            if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR){
77 77
                 if (
78 78
                     $this->echo->nextToken($src) ||
79 79
                     $this->raw->nextToken($src) ||
80 80
                     $src->lookaheadByte() === DirectiveGrammar::DIRECTIVE_CHAR
81
-                ) {
81
+                ){
82 82
                     // escaped echo sequence, hide directive byte
83 83
                     yield $src->next();
84 84
                     continue;
85 85
                 }
86 86
 
87 87
                 $directive = new DirectiveGrammar();
88
-                if ($directive->parse($src, $n->offset)) {
89
-                    if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE) {
88
+                if ($directive->parse($src, $n->offset)){
89
+                    if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE){
90 90
                         // configure braces syntax
91 91
                         $this->declare($directive->getBody());
92
-                    } else {
92
+                    }else{
93 93
                         if (
94 94
                             $this->directiveRenderer instanceof \Spiral\Stempler\Directive\DirectiveRendererInterface
95 95
                             && !$this->directiveRenderer->hasDirective($directive->getKeyword())
96
-                        ) {
96
+                        ){
97 97
                             // directive opening char
98 98
                             yield $n;
99 99
 
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 
115 115
             /** @var BracesGrammar|null $braces */
116 116
             $braces = null;
117
-            if ($this->echo->starts($src, $n)) {
117
+            if ($this->echo->starts($src, $n)){
118 118
                 $braces = clone $this->echo;
119
-            } elseif ($this->raw->starts($src, $n)) {
119
+            } elseif ($this->raw->starts($src, $n)){
120 120
                 $braces = clone $this->raw;
121 121
             }
122 122
 
123
-            if ($braces !== null) {
123
+            if ($braces !== null){
124 124
                 $echo = $braces->parse($src, $n);
125
-                if ($echo !== null) {
125
+                if ($echo !== null){
126 126
                     yield from $echo;
127 127
                     continue;
128 128
                 }
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
         };
155 155
     }
156 156
 
157
-    private function declare(?string $body): void
157
+    private function declare(?string$body) : void
158 158
     {
159
-        if ($body === null) {
159
+        if ($body === null){
160 160
             return;
161 161
         }
162 162
 
163
-        foreach ($this->fetchOptions($body) as $option => $value) {
164
-            $value = \trim((string) $value, '\'" ');
165
-            switch ($option) {
163
+        foreach ($this->fetchOptions($body) as $option => $value){
164
+            $value = \trim((string)$value, '\'" ');
165
+            switch ($option){
166 166
                 case 'syntax':
167 167
                     $this->echo->setActive($value !== 'off');
168 168
                     $this->raw->setActive($value !== 'off');
169 169
 
170
-                    if ($value === 'default') {
170
+                    if ($value === 'default'){
171 171
                         $this->echo->setStartSequence('{{');
172 172
                         $this->echo->setEndSequence('}}');
173 173
                         $this->raw->setStartSequence('{!!');
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
         $keyword = null;
205 205
 
206 206
         /** @var Token $token */
207
-        foreach ($lexer->parse(new StringStream($body)) as $token) {
208
-            switch ($token->type) {
207
+        foreach ($lexer->parse(new StringStream($body)) as $token){
208
+            switch ($token->type){
209 209
                 case DeclareGrammar::TYPE_KEYWORD:
210
-                    if ($keyword !== null) {
210
+                    if ($keyword !== null){
211 211
                         $options[$keyword] = $token->content;
212 212
                         $keyword = null;
213 213
                         break;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                     $keyword = $token->content;
216 216
                     break;
217 217
                 case DeclareGrammar::TYPE_QUOTED:
218
-                    if ($keyword !== null) {
218
+                    if ($keyword !== null){
219 219
                         $options[$keyword] = \trim($token->content, $token->content[0]);
220 220
                         $keyword = null;
221 221
                         break;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
                     $keyword = \trim($token->content, $token->content[0]);
225 225
                     break;
226 226
                 case DeclareGrammar::TYPE_COMMA:
227
-                    if ($keyword !== null) {
227
+                    if ($keyword !== null){
228 228
                         $options[$keyword] = null;
229 229
                         $keyword = null;
230 230
                         break;
Please login to merge, or discard this patch.
Braces   +40 added lines, -19 removed lines patch added patch discarded remove patch
@@ -67,13 +67,16 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function parse(Buffer $src): \Generator
69 69
     {
70
-        while ($n = $src->next()) {
71
-            if (!$n instanceof Byte) {
70
+        while ($n = $src->next())
71
+        {
72
+            if (!$n instanceof Byte)
73
+            {
72 74
                 yield $n;
73 75
                 continue;
74 76
             }
75 77
 
76
-            if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR) {
78
+            if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR)
79
+            {
77 80
                 if (
78 81
                     $this->echo->nextToken($src) ||
79 82
                     $this->raw->nextToken($src) ||
@@ -85,11 +88,15 @@  discard block
 block discarded – undo
85 88
                 }
86 89
 
87 90
                 $directive = new DirectiveGrammar();
88
-                if ($directive->parse($src, $n->offset)) {
89
-                    if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE) {
91
+                if ($directive->parse($src, $n->offset))
92
+                {
93
+                    if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE)
94
+                    {
90 95
                         // configure braces syntax
91 96
                         $this->declare($directive->getBody());
92
-                    } else {
97
+                    }
98
+                    else
99
+                    {
93 100
                         if (
94 101
                             $this->directiveRenderer instanceof \Spiral\Stempler\Directive\DirectiveRendererInterface
95 102
                             && !$this->directiveRenderer->hasDirective($directive->getKeyword())
@@ -114,15 +121,20 @@  discard block
 block discarded – undo
114 121
 
115 122
             /** @var BracesGrammar|null $braces */
116 123
             $braces = null;
117
-            if ($this->echo->starts($src, $n)) {
124
+            if ($this->echo->starts($src, $n))
125
+            {
118 126
                 $braces = clone $this->echo;
119
-            } elseif ($this->raw->starts($src, $n)) {
127
+            }
128
+            elseif ($this->raw->starts($src, $n))
129
+            {
120 130
                 $braces = clone $this->raw;
121 131
             }
122 132
 
123
-            if ($braces !== null) {
133
+            if ($braces !== null)
134
+            {
124 135
                 $echo = $braces->parse($src, $n);
125
-                if ($echo !== null) {
136
+                if ($echo !== null)
137
+                {
126 138
                     yield from $echo;
127 139
                     continue;
128 140
                 }
@@ -156,18 +168,22 @@  discard block
 block discarded – undo
156 168
 
157 169
     private function declare(?string $body): void
158 170
     {
159
-        if ($body === null) {
171
+        if ($body === null)
172
+        {
160 173
             return;
161 174
         }
162 175
 
163
-        foreach ($this->fetchOptions($body) as $option => $value) {
176
+        foreach ($this->fetchOptions($body) as $option => $value)
177
+        {
164 178
             $value = \trim((string) $value, '\'" ');
165
-            switch ($option) {
179
+            switch ($option)
180
+            {
166 181
                 case 'syntax':
167 182
                     $this->echo->setActive($value !== 'off');
168 183
                     $this->raw->setActive($value !== 'off');
169 184
 
170
-                    if ($value === 'default') {
185
+                    if ($value === 'default')
186
+                    {
171 187
                         $this->echo->setStartSequence('{{');
172 188
                         $this->echo->setEndSequence('}}');
173 189
                         $this->raw->setStartSequence('{!!');
@@ -204,10 +220,13 @@  discard block
 block discarded – undo
204 220
         $keyword = null;
205 221
 
206 222
         /** @var Token $token */
207
-        foreach ($lexer->parse(new StringStream($body)) as $token) {
208
-            switch ($token->type) {
223
+        foreach ($lexer->parse(new StringStream($body)) as $token)
224
+        {
225
+            switch ($token->type)
226
+            {
209 227
                 case DeclareGrammar::TYPE_KEYWORD:
210
-                    if ($keyword !== null) {
228
+                    if ($keyword !== null)
229
+                    {
211 230
                         $options[$keyword] = $token->content;
212 231
                         $keyword = null;
213 232
                         break;
@@ -215,7 +234,8 @@  discard block
 block discarded – undo
215 234
                     $keyword = $token->content;
216 235
                     break;
217 236
                 case DeclareGrammar::TYPE_QUOTED:
218
-                    if ($keyword !== null) {
237
+                    if ($keyword !== null)
238
+                    {
219 239
                         $options[$keyword] = \trim($token->content, $token->content[0]);
220 240
                         $keyword = null;
221 241
                         break;
@@ -224,7 +244,8 @@  discard block
 block discarded – undo
224 244
                     $keyword = \trim($token->content, $token->content[0]);
225 245
                     break;
226 246
                 case DeclareGrammar::TYPE_COMMA:
227
-                    if ($keyword !== null) {
247
+                    if ($keyword !== null)
248
+                    {
228 249
                         $options[$keyword] = null;
229 250
                         $keyword = null;
230 251
                         break;
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/PHPGrammar.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function parse(Buffer $src): \Generator
18 18
     {
19
-        while ($n = $src->next()) {
20
-            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?') {
19
+        while ($n = $src->next()){
20
+            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?'){
21 21
                 yield $n;
22 22
                 continue;
23 23
             }
24 24
 
25
-            $php = $this->parseGrammar($n->char . $src->nextBytes(), $n->offset);
26
-            if (!$php instanceof \Spiral\Stempler\Lexer\Token) {
25
+            $php = $this->parseGrammar($n->char.$src->nextBytes(), $n->offset);
26
+            if (!$php instanceof \Spiral\Stempler\Lexer\Token){
27 27
                 yield $n;
28 28
                 $src->replay($n->offset);
29 29
                 continue;
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
     private function parseGrammar(string $content, int $offset): ?Token
46 46
     {
47 47
         $tokens = null;
48
-        foreach (\token_get_all($content) as $token) {
49
-            if ($tokens === null && !$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])) {
48
+        foreach (\token_get_all($content) as $token){
49
+            if ($tokens === null && !$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])){
50 50
                 // not php
51 51
                 return null;
52 52
             }
53 53
 
54 54
             $tokens[] = $token;
55
-            if ($this->is($token, [T_CLOSE_TAG])) {
55
+            if ($this->is($token, [T_CLOSE_TAG])){
56 56
                 break;
57 57
             }
58 58
         }
59 59
 
60
-        if ($tokens === null) {
60
+        if ($tokens === null){
61 61
             return null;
62 62
         }
63 63
 
64 64
         $buffer = '';
65
-        foreach ($tokens as $token) {
66
-            if (!\is_array($token)) {
65
+        foreach ($tokens as $token){
66
+            if (!\is_array($token)){
67 67
                 $buffer .= $token;
68 68
                 continue;
69 69
             }
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
         return $token;
77 77
     }
78 78
 
79
-    private function is(array|string $token, array $type): bool
79
+    private function is(array | string $token, array $type): bool
80 80
     {
81
-        if (!\is_array($token)) {
81
+        if (!\is_array($token)){
82 82
             return false;
83 83
         }
84 84
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,14 +16,17 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function parse(Buffer $src): \Generator
18 18
     {
19
-        while ($n = $src->next()) {
20
-            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?') {
19
+        while ($n = $src->next())
20
+        {
21
+            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?')
22
+            {
21 23
                 yield $n;
22 24
                 continue;
23 25
             }
24 26
 
25 27
             $php = $this->parseGrammar($n->char . $src->nextBytes(), $n->offset);
26
-            if (!$php instanceof \Spiral\Stempler\Lexer\Token) {
28
+            if (!$php instanceof \Spiral\Stempler\Lexer\Token)
29
+            {
27 30
                 yield $n;
28 31
                 $src->replay($n->offset);
29 32
                 continue;
@@ -45,25 +48,31 @@  discard block
 block discarded – undo
45 48
     private function parseGrammar(string $content, int $offset): ?Token
46 49
     {
47 50
         $tokens = null;
48
-        foreach (\token_get_all($content) as $token) {
49
-            if ($tokens === null && !$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])) {
51
+        foreach (\token_get_all($content) as $token)
52
+        {
53
+            if ($tokens === null && !$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO]))
54
+            {
50 55
                 // not php
51 56
                 return null;
52 57
             }
53 58
 
54 59
             $tokens[] = $token;
55
-            if ($this->is($token, [T_CLOSE_TAG])) {
60
+            if ($this->is($token, [T_CLOSE_TAG]))
61
+            {
56 62
                 break;
57 63
             }
58 64
         }
59 65
 
60
-        if ($tokens === null) {
66
+        if ($tokens === null)
67
+        {
61 68
             return null;
62 69
         }
63 70
 
64 71
         $buffer = '';
65
-        foreach ($tokens as $token) {
66
-            if (!\is_array($token)) {
72
+        foreach ($tokens as $token)
73
+        {
74
+            if (!\is_array($token))
75
+            {
67 76
                 $buffer .= $token;
68 77
                 continue;
69 78
             }
@@ -78,7 +87,8 @@  discard block
 block discarded – undo
78 87
 
79 88
     private function is(array|string $token, array $type): bool
80 89
     {
81
-        if (!\is_array($token)) {
90
+        if (!\is_array($token))
91
+        {
82 92
             return false;
83 93
         }
84 94
 
Please login to merge, or discard this patch.
src/Stempler/src/Parser/Syntax/DynamicSyntax.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
     public function handle(Parser $parser, Assembler $asm, Token $token): void
25 25
     {
26
-        switch ($token->type) {
26
+        switch ($token->type){
27 27
             case DynamicGrammar::TYPE_DIRECTIVE:
28 28
                 $this->directive = new Directive(new Parser\Context($token, $parser->getPath()));
29 29
                 $asm->push($this->directive);
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
                 break;
49 49
 
50 50
             case DynamicGrammar::TYPE_KEYWORD:
51
-                if ($this->directive instanceof \Spiral\Stempler\Node\Dynamic\Directive) {
51
+                if ($this->directive instanceof \Spiral\Stempler\Node\Dynamic\Directive){
52 52
                     $this->directive->name = $token->content;
53 53
                 }
54 54
                 break;
55 55
 
56 56
             case DynamicGrammar::TYPE_BODY:
57
-                if ($this->directive instanceof \Spiral\Stempler\Node\Dynamic\Directive) {
57
+                if ($this->directive instanceof \Spiral\Stempler\Node\Dynamic\Directive){
58 58
                     $this->directive->body = $token->content;
59 59
                     $this->directive->values = $this->fetchValues($this->directive->body);
60 60
 
61 61
                     $this->directive = null;
62 62
                 }
63 63
 
64
-                if ($this->output instanceof \Spiral\Stempler\Node\Dynamic\Output) {
64
+                if ($this->output instanceof \Spiral\Stempler\Node\Dynamic\Output){
65 65
                     $this->output->body = $token->content;
66 66
                 }
67 67
 
@@ -79,31 +79,31 @@  discard block
 block discarded – undo
79 79
 
80 80
         $src = new StringStream($body);
81 81
 
82
-        while ($n = $src->peak()) {
83
-            if (\in_array($n, ['"', "'"], true)) {
82
+        while ($n = $src->peak()){
83
+            if (\in_array($n, ['"', "'"], true)){
84 84
                 $values[\count($values) - 1] .= $n;
85
-                while (($nn = $src->peak()) !== null) {
85
+                while (($nn = $src->peak()) !== null){
86 86
                     $values[\count($values) - 1] .= $nn;
87
-                    if ($nn === $n) {
87
+                    if ($nn === $n){
88 88
                         break;
89 89
                     }
90 90
                 }
91 91
                 continue;
92 92
             }
93 93
 
94
-            if ($n === ',' && $level === 0) {
94
+            if ($n === ',' && $level === 0){
95 95
                 $values[] = '';
96 96
                 continue;
97 97
             }
98 98
 
99 99
             $values[\count($values) - 1] .= $n;
100 100
 
101
-            if ($n === '(' || $n === '[' || $n === '{') {
101
+            if ($n === '(' || $n === '[' || $n === '{'){
102 102
                 $level++;
103 103
                 continue;
104 104
             }
105 105
 
106
-            if ($n === ')' || $n === ']' || $n === '}') {
106
+            if ($n === ')' || $n === ']' || $n === '}'){
107 107
                 $level--;
108 108
             }
109 109
         }
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,7 +23,8 @@  discard block
 block discarded – undo
23 23
 
24 24
     public function handle(Parser $parser, Assembler $asm, Token $token): void
25 25
     {
26
-        switch ($token->type) {
26
+        switch ($token->type)
27
+        {
27 28
             case DynamicGrammar::TYPE_DIRECTIVE:
28 29
                 $this->directive = new Directive(new Parser\Context($token, $parser->getPath()));
29 30
                 $asm->push($this->directive);
@@ -48,20 +49,23 @@  discard block
 block discarded – undo
48 49
                 break;
49 50
 
50 51
             case DynamicGrammar::TYPE_KEYWORD:
51
-                if ($this->directive instanceof \Spiral\Stempler\Node\Dynamic\Directive) {
52
+                if ($this->directive instanceof \Spiral\Stempler\Node\Dynamic\Directive)
53
+                {
52 54
                     $this->directive->name = $token->content;
53 55
                 }
54 56
                 break;
55 57
 
56 58
             case DynamicGrammar::TYPE_BODY:
57
-                if ($this->directive instanceof \Spiral\Stempler\Node\Dynamic\Directive) {
59
+                if ($this->directive instanceof \Spiral\Stempler\Node\Dynamic\Directive)
60
+                {
58 61
                     $this->directive->body = $token->content;
59 62
                     $this->directive->values = $this->fetchValues($this->directive->body);
60 63
 
61 64
                     $this->directive = null;
62 65
                 }
63 66
 
64
-                if ($this->output instanceof \Spiral\Stempler\Node\Dynamic\Output) {
67
+                if ($this->output instanceof \Spiral\Stempler\Node\Dynamic\Output)
68
+                {
65 69
                     $this->output->body = $token->content;
66 70
                 }
67 71
 
@@ -79,31 +83,38 @@  discard block
 block discarded – undo
79 83
 
80 84
         $src = new StringStream($body);
81 85
 
82
-        while ($n = $src->peak()) {
83
-            if (\in_array($n, ['"', "'"], true)) {
86
+        while ($n = $src->peak())
87
+        {
88
+            if (\in_array($n, ['"', "'"], true))
89
+            {
84 90
                 $values[\count($values) - 1] .= $n;
85
-                while (($nn = $src->peak()) !== null) {
91
+                while (($nn = $src->peak()) !== null)
92
+                {
86 93
                     $values[\count($values) - 1] .= $nn;
87
-                    if ($nn === $n) {
94
+                    if ($nn === $n)
95
+                    {
88 96
                         break;
89 97
                     }
90 98
                 }
91 99
                 continue;
92 100
             }
93 101
 
94
-            if ($n === ',' && $level === 0) {
102
+            if ($n === ',' && $level === 0)
103
+            {
95 104
                 $values[] = '';
96 105
                 continue;
97 106
             }
98 107
 
99 108
             $values[\count($values) - 1] .= $n;
100 109
 
101
-            if ($n === '(' || $n === '[' || $n === '{') {
110
+            if ($n === '(' || $n === '[' || $n === '{')
111
+            {
102 112
                 $level++;
103 113
                 continue;
104 114
             }
105 115
 
106
-            if ($n === ')' || $n === ']' || $n === '}') {
116
+            if ($n === ')' || $n === ']' || $n === '}')
117
+            {
107 118
                 $level--;
108 119
             }
109 120
         }
Please login to merge, or discard this patch.
src/Stempler/src/Parser/Syntax/HTMLSyntax.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     public function handle(Parser $parser, Assembler $asm, Token $token): void
56 56
     {
57
-        switch ($token->type) {
57
+        switch ($token->type){
58 58
             case HTMLGrammar::TYPE_OPEN:
59 59
             case HTMLGrammar::TYPE_OPEN_SHORT:
60 60
                 $this->node = new Tag(new Parser\Context($token, $parser->getPath()));
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
                 break;
64 64
 
65 65
             case HTMLGrammar::TYPE_KEYWORD:
66
-                if ($this->node->name === null) {
66
+                if ($this->node->name === null){
67 67
                     $this->node->name = $this->parseToken($parser, $token);
68 68
                     return;
69 69
                 }
70 70
 
71
-                if ($this->attr instanceof \Spiral\Stempler\Node\HTML\Attr && !$this->attr->value instanceof Nil) {
71
+                if ($this->attr instanceof \Spiral\Stempler\Node\HTML\Attr && !$this->attr->value instanceof Nil){
72 72
                     $this->attr->value = $this->parseToken($parser, $token);
73 73
                     $this->attr = null;
74 74
                     break;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 break;
85 85
 
86 86
             case HTMLGrammar::TYPE_EQUAL:
87
-                if (!$this->attr instanceof \Spiral\Stempler\Node\HTML\Attr) {
87
+                if (!$this->attr instanceof \Spiral\Stempler\Node\HTML\Attr){
88 88
                     throw new SyntaxException('unexpected attribute token', $token);
89 89
                 }
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                 break;
94 94
 
95 95
             case HTMLGrammar::TYPE_ATTRIBUTE:
96
-                if (!$this->attr instanceof \Spiral\Stempler\Node\HTML\Attr) {
96
+                if (!$this->attr instanceof \Spiral\Stempler\Node\HTML\Attr){
97 97
                     throw new SyntaxException('unexpected attribute token', $token);
98 98
                 }
99 99
 
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
                         \str_starts_with($this->attr->name, 'on')
104 104
                         || \in_array($this->attr->name, self::VERBATIM_ATTRIBUTES, true)
105 105
                     )
106
-                ) {
106
+                ){
107 107
                     $this->attr->value = $this->parseVerbatim($parser, $token);
108
-                } else {
108
+                }else{
109 109
                     $this->attr->value = $this->parseToken($parser, $token);
110 110
                 }
111 111
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
                 break;
120 120
 
121 121
             case HTMLGrammar::TYPE_CLOSE:
122
-                if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) {
123
-                    if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) {
122
+                if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT){
123
+                    if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name){
124 124
                         /**
125 125
                          * TODO issue #767
126 126
                          * @link https://github.com/spiral/framework/issues/767
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
                     }
134 134
 
135 135
                     $asm->close();
136
-                } elseif (\in_array($this->node->name, self::VOID_TAGS)) {
136
+                } elseif (\in_array($this->node->name, self::VOID_TAGS)){
137 137
                     $this->node->void = true;
138 138
                     $asm->push($this->node);
139
-                } else {
139
+                }else{
140 140
                     $asm->open($this->node, 'nodes');
141 141
                 }
142 142
                 $this->flush();
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
                 break;
149 149
 
150 150
             default:
151
-                if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) {
151
+                if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim){
152 152
                     $node = $this->parseToken($parser, $token);
153
-                    if (\is_string($node)) {
153
+                    if (\is_string($node)){
154 154
                         $node = new Raw($node, new Parser\Context($token, $parser->getPath()));
155 155
                     }
156 156
 
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
     {
174 174
         $verbatim = new Verbatim(new Parser\Context($token, $parser->getPath()));
175 175
 
176
-        if ($token->tokens === []) {
177
-            if ($token->content) {
176
+        if ($token->tokens === []){
177
+            if ($token->content){
178 178
                 $verbatim->nodes[] = $token->content;
179 179
             }
180
-        } else {
180
+        }else{
181 181
             /**
182 182
              * TODO issue #767
183 183
              * @link https://github.com/spiral/framework/issues/767
Please login to merge, or discard this patch.
Braces   +34 added lines, -15 removed lines patch added patch discarded remove patch
@@ -54,7 +54,8 @@  discard block
 block discarded – undo
54 54
 
55 55
     public function handle(Parser $parser, Assembler $asm, Token $token): void
56 56
     {
57
-        switch ($token->type) {
57
+        switch ($token->type)
58
+        {
58 59
             case HTMLGrammar::TYPE_OPEN:
59 60
             case HTMLGrammar::TYPE_OPEN_SHORT:
60 61
                 $this->node = new Tag(new Parser\Context($token, $parser->getPath()));
@@ -63,12 +64,14 @@  discard block
 block discarded – undo
63 64
                 break;
64 65
 
65 66
             case HTMLGrammar::TYPE_KEYWORD:
66
-                if ($this->node->name === null) {
67
+                if ($this->node->name === null)
68
+                {
67 69
                     $this->node->name = $this->parseToken($parser, $token);
68 70
                     return;
69 71
                 }
70 72
 
71
-                if ($this->attr instanceof \Spiral\Stempler\Node\HTML\Attr && !$this->attr->value instanceof Nil) {
73
+                if ($this->attr instanceof \Spiral\Stempler\Node\HTML\Attr && !$this->attr->value instanceof Nil)
74
+                {
72 75
                     $this->attr->value = $this->parseToken($parser, $token);
73 76
                     $this->attr = null;
74 77
                     break;
@@ -84,7 +87,8 @@  discard block
 block discarded – undo
84 87
                 break;
85 88
 
86 89
             case HTMLGrammar::TYPE_EQUAL:
87
-                if (!$this->attr instanceof \Spiral\Stempler\Node\HTML\Attr) {
90
+                if (!$this->attr instanceof \Spiral\Stempler\Node\HTML\Attr)
91
+                {
88 92
                     throw new SyntaxException('unexpected attribute token', $token);
89 93
                 }
90 94
 
@@ -93,7 +97,8 @@  discard block
 block discarded – undo
93 97
                 break;
94 98
 
95 99
             case HTMLGrammar::TYPE_ATTRIBUTE:
96
-                if (!$this->attr instanceof \Spiral\Stempler\Node\HTML\Attr) {
100
+                if (!$this->attr instanceof \Spiral\Stempler\Node\HTML\Attr)
101
+                {
97 102
                     throw new SyntaxException('unexpected attribute token', $token);
98 103
                 }
99 104
 
@@ -105,7 +110,9 @@  discard block
 block discarded – undo
105 110
                     )
106 111
                 ) {
107 112
                     $this->attr->value = $this->parseVerbatim($parser, $token);
108
-                } else {
113
+                }
114
+                else
115
+                {
109 116
                     $this->attr->value = $this->parseToken($parser, $token);
110 117
                 }
111 118
 
@@ -119,8 +126,10 @@  discard block
 block discarded – undo
119 126
                 break;
120 127
 
121 128
             case HTMLGrammar::TYPE_CLOSE:
122
-                if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) {
123
-                    if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) {
129
+                if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT)
130
+                {
131
+                    if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name)
132
+                    {
124 133
                         /**
125 134
                          * TODO issue #767
126 135
                          * @link https://github.com/spiral/framework/issues/767
@@ -133,10 +142,14 @@  discard block
 block discarded – undo
133 142
                     }
134 143
 
135 144
                     $asm->close();
136
-                } elseif (\in_array($this->node->name, self::VOID_TAGS)) {
145
+                }
146
+                elseif (\in_array($this->node->name, self::VOID_TAGS))
147
+                {
137 148
                     $this->node->void = true;
138 149
                     $asm->push($this->node);
139
-                } else {
150
+                }
151
+                else
152
+                {
140 153
                     $asm->open($this->node, 'nodes');
141 154
                 }
142 155
                 $this->flush();
@@ -148,9 +161,11 @@  discard block
 block discarded – undo
148 161
                 break;
149 162
 
150 163
             default:
151
-                if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) {
164
+                if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim)
165
+                {
152 166
                     $node = $this->parseToken($parser, $token);
153
-                    if (\is_string($node)) {
167
+                    if (\is_string($node))
168
+                    {
154 169
                         $node = new Raw($node, new Parser\Context($token, $parser->getPath()));
155 170
                     }
156 171
 
@@ -173,11 +188,15 @@  discard block
 block discarded – undo
173 188
     {
174 189
         $verbatim = new Verbatim(new Parser\Context($token, $parser->getPath()));
175 190
 
176
-        if ($token->tokens === []) {
177
-            if ($token->content) {
191
+        if ($token->tokens === [])
192
+        {
193
+            if ($token->content)
194
+            {
178 195
                 $verbatim->nodes[] = $token->content;
179 196
             }
180
-        } else {
197
+        }
198
+        else
199
+        {
181 200
             /**
182 201
              * TODO issue #767
183 202
              * @link https://github.com/spiral/framework/issues/767
Please login to merge, or discard this patch.
src/Prototype/src/Traits/PrototypeTrait.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function __get(string $name): mixed
21 21
     {
22 22
         $container = ContainerScope::getContainer();
23
-        if (!$container instanceof \Psr\Container\ContainerInterface || !$container->has(PrototypeRegistry::class)) {
23
+        if (!$container instanceof \Psr\Container\ContainerInterface || !$container->has(PrototypeRegistry::class)){
24 24
             throw new ScopeException(
25 25
                 \sprintf('Unable to resolve prototyped dependency `%s`, invalid container scope', $name)
26 26
             );
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             $target === null ||
35 35
             $target instanceof \Throwable ||
36 36
             $target->type->fullName === null
37
-        ) {
37
+        ){
38 38
             throw new PrototypeException(
39 39
                 \sprintf('Undefined prototype property `%s`', $name),
40 40
                 0,
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
20 20
     public function __get(string $name): mixed
21 21
     {
22 22
         $container = ContainerScope::getContainer();
23
-        if (!$container instanceof \Psr\Container\ContainerInterface || !$container->has(PrototypeRegistry::class)) {
23
+        if (!$container instanceof \Psr\Container\ContainerInterface || !$container->has(PrototypeRegistry::class))
24
+        {
24 25
             throw new ScopeException(
25 26
                 \sprintf('Unable to resolve prototyped dependency `%s`, invalid container scope', $name)
26 27
             );
Please login to merge, or discard this patch.
src/Prototype/src/ClassNode/ConflictResolver/Namespaces.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 {
12 12
     public function __construct(
13 13
         private readonly Sequences $sequences
14
-    ) {
14
+    ){
15 15
     }
16 16
 
17 17
     public function resolve(ClassNode $definition): void
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 
33 33
     private function getReservedNamespacesWithAlias(ClassNode $definition, array $namespaces): array
34 34
     {
35
-        foreach ($definition->getStmts() as $stmt) {
36
-            if (!$stmt->alias) {
35
+        foreach ($definition->getStmts() as $stmt){
36
+            if (!$stmt->alias){
37 37
                 continue;
38 38
             }
39 39
 
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 
46 46
     private function getReservedNamespacesWithoutAlias(ClassNode $definition, array $namespaces): array
47 47
     {
48
-        foreach ($definition->getStmts() as $stmt) {
49
-            if ($stmt->alias || isset($namespaces[$stmt->shortName])) {
48
+        foreach ($definition->getStmts() as $stmt){
49
+            if ($stmt->alias || isset($namespaces[$stmt->shortName])){
50 50
                 continue;
51 51
             }
52 52
 
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
     private function initiateCounters(array $namespaces): array
60 60
     {
61 61
         $counters = [];
62
-        foreach ($namespaces as $shortName => $fullName) {
62
+        foreach ($namespaces as $shortName => $fullName){
63 63
             $namespace = $this->parseNamespace($shortName, $fullName);
64 64
 
65
-            if (isset($counters[$namespace->name])) {
65
+            if (isset($counters[$namespace->name])){
66 66
                 $counters[$namespace->name][$namespace->sequence] = $namespace;
67
-            } else {
67
+            }else{
68 68
                 $counters[$namespace->name] = [$namespace->sequence => $namespace];
69 69
             }
70 70
         }
@@ -74,52 +74,52 @@  discard block
 block discarded – undo
74 74
 
75 75
     private function resolveImportsNamespaces(ClassNode $definition, array $counters): void
76 76
     {
77
-        if (!$definition->hasConstructor && $definition->constructorParams) {
78
-            foreach ($definition->constructorParams as $param) {
77
+        if (!$definition->hasConstructor && $definition->constructorParams){
78
+            foreach ($definition->constructorParams as $param){
79 79
                 //no type (or type is internal), do nothing
80
-                if (empty($param->type) || $param->isBuiltIn()) {
80
+                if (empty($param->type) || $param->isBuiltIn()){
81 81
                     continue;
82 82
                 }
83 83
 
84 84
                 $namespace = $this->parseNamespaceFromType($param->type);
85
-                if (isset($counters[$namespace->name])) {
86
-                    if ($this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace)) {
85
+                if (isset($counters[$namespace->name])){
86
+                    if ($this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace)){
87 87
                         continue;
88 88
                     }
89 89
 
90 90
                     $sequence = $this->sequences->find(\array_keys($counters[$namespace->name]), $namespace->sequence);
91
-                    if ($sequence !== $namespace->sequence) {
91
+                    if ($sequence !== $namespace->sequence){
92 92
                         $namespace->sequence = $sequence;
93 93
 
94 94
                         $param->type->alias = $namespace->fullName();
95 95
                     }
96 96
 
97 97
                     $counters[$namespace->name][$sequence] = $namespace;
98
-                } else {
98
+                }else{
99 99
                     $counters[$namespace->name] = [$namespace->sequence => $namespace];
100 100
                 }
101 101
             }
102 102
         }
103 103
 
104
-        foreach ($definition->dependencies as $dependency) {
104
+        foreach ($definition->dependencies as $dependency){
105 105
             $namespace = $this->parseNamespaceFromType($dependency->type);
106
-            if (isset($counters[$namespace->name])) {
106
+            if (isset($counters[$namespace->name])){
107 107
                 $alreadyImported = $this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace);
108
-                if ($alreadyImported instanceof \Spiral\Prototype\ClassNode\ConflictResolver\NamespaceEntity) {
108
+                if ($alreadyImported instanceof \Spiral\Prototype\ClassNode\ConflictResolver\NamespaceEntity){
109 109
                     $dependency->type->alias = $alreadyImported->fullName();
110 110
 
111 111
                     continue;
112 112
                 }
113 113
 
114 114
                 $sequence = $this->sequences->find(\array_keys($counters[$namespace->name]), $namespace->sequence);
115
-                if ($sequence !== $namespace->sequence) {
115
+                if ($sequence !== $namespace->sequence){
116 116
                     $namespace->sequence = $sequence;
117 117
 
118 118
                     $dependency->type->alias = $namespace->fullName();
119 119
                 }
120 120
 
121 121
                 $counters[$namespace->name][$sequence] = $namespace;
122
-            } else {
122
+            }else{
123 123
                 $counters[$namespace->name] = [$namespace->sequence => $namespace];
124 124
             }
125 125
         }
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
      */
131 131
     private function getAlreadyImportedNamespace(array $counters, NamespaceEntity $namespace): ?NamespaceEntity
132 132
     {
133
-        foreach ($counters as $counter) {
134
-            if ($counter->equals($namespace)) {
133
+        foreach ($counters as $counter){
134
+            if ($counter->equals($namespace)){
135 135
                 return $counter;
136 136
             }
137 137
         }
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 
147 147
     private function parseNamespace(string $shortName, string $fullName): NamespaceEntity
148 148
     {
149
-        if (\preg_match("/\d+$/", $shortName, $match)) {
149
+        if (\preg_match("/\d+$/", $shortName, $match)){
150 150
             $sequence = (int)$match[0];
151
-            if ($sequence > 0) {
151
+            if ($sequence > 0){
152 152
                 return NamespaceEntity::createWithSequence(
153 153
                     Utils::trimTrailingDigits($shortName, $sequence),
154 154
                     $fullName,
Please login to merge, or discard this patch.
Braces   +49 added lines, -23 removed lines patch added patch discarded remove patch
@@ -32,8 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
     private function getReservedNamespacesWithAlias(ClassNode $definition, array $namespaces): array
34 34
     {
35
-        foreach ($definition->getStmts() as $stmt) {
36
-            if (!$stmt->alias) {
35
+        foreach ($definition->getStmts() as $stmt)
36
+        {
37
+            if (!$stmt->alias)
38
+            {
37 39
                 continue;
38 40
             }
39 41
 
@@ -45,8 +47,10 @@  discard block
 block discarded – undo
45 47
 
46 48
     private function getReservedNamespacesWithoutAlias(ClassNode $definition, array $namespaces): array
47 49
     {
48
-        foreach ($definition->getStmts() as $stmt) {
49
-            if ($stmt->alias || isset($namespaces[$stmt->shortName])) {
50
+        foreach ($definition->getStmts() as $stmt)
51
+        {
52
+            if ($stmt->alias || isset($namespaces[$stmt->shortName]))
53
+            {
50 54
                 continue;
51 55
             }
52 56
 
@@ -59,12 +63,16 @@  discard block
 block discarded – undo
59 63
     private function initiateCounters(array $namespaces): array
60 64
     {
61 65
         $counters = [];
62
-        foreach ($namespaces as $shortName => $fullName) {
66
+        foreach ($namespaces as $shortName => $fullName)
67
+        {
63 68
             $namespace = $this->parseNamespace($shortName, $fullName);
64 69
 
65
-            if (isset($counters[$namespace->name])) {
70
+            if (isset($counters[$namespace->name]))
71
+            {
66 72
                 $counters[$namespace->name][$namespace->sequence] = $namespace;
67
-            } else {
73
+            }
74
+            else
75
+            {
68 76
                 $counters[$namespace->name] = [$namespace->sequence => $namespace];
69 77
             }
70 78
         }
@@ -74,52 +82,66 @@  discard block
 block discarded – undo
74 82
 
75 83
     private function resolveImportsNamespaces(ClassNode $definition, array $counters): void
76 84
     {
77
-        if (!$definition->hasConstructor && $definition->constructorParams) {
78
-            foreach ($definition->constructorParams as $param) {
85
+        if (!$definition->hasConstructor && $definition->constructorParams)
86
+        {
87
+            foreach ($definition->constructorParams as $param)
88
+            {
79 89
                 //no type (or type is internal), do nothing
80
-                if (empty($param->type) || $param->isBuiltIn()) {
90
+                if (empty($param->type) || $param->isBuiltIn())
91
+                {
81 92
                     continue;
82 93
                 }
83 94
 
84 95
                 $namespace = $this->parseNamespaceFromType($param->type);
85
-                if (isset($counters[$namespace->name])) {
86
-                    if ($this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace)) {
96
+                if (isset($counters[$namespace->name]))
97
+                {
98
+                    if ($this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace))
99
+                    {
87 100
                         continue;
88 101
                     }
89 102
 
90 103
                     $sequence = $this->sequences->find(\array_keys($counters[$namespace->name]), $namespace->sequence);
91
-                    if ($sequence !== $namespace->sequence) {
104
+                    if ($sequence !== $namespace->sequence)
105
+                    {
92 106
                         $namespace->sequence = $sequence;
93 107
 
94 108
                         $param->type->alias = $namespace->fullName();
95 109
                     }
96 110
 
97 111
                     $counters[$namespace->name][$sequence] = $namespace;
98
-                } else {
112
+                }
113
+                else
114
+                {
99 115
                     $counters[$namespace->name] = [$namespace->sequence => $namespace];
100 116
                 }
101 117
             }
102 118
         }
103 119
 
104
-        foreach ($definition->dependencies as $dependency) {
120
+        foreach ($definition->dependencies as $dependency)
121
+        {
105 122
             $namespace = $this->parseNamespaceFromType($dependency->type);
106
-            if (isset($counters[$namespace->name])) {
123
+            if (isset($counters[$namespace->name]))
124
+            {
107 125
                 $alreadyImported = $this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace);
108
-                if ($alreadyImported instanceof \Spiral\Prototype\ClassNode\ConflictResolver\NamespaceEntity) {
126
+                if ($alreadyImported instanceof \Spiral\Prototype\ClassNode\ConflictResolver\NamespaceEntity)
127
+                {
109 128
                     $dependency->type->alias = $alreadyImported->fullName();
110 129
 
111 130
                     continue;
112 131
                 }
113 132
 
114 133
                 $sequence = $this->sequences->find(\array_keys($counters[$namespace->name]), $namespace->sequence);
115
-                if ($sequence !== $namespace->sequence) {
134
+                if ($sequence !== $namespace->sequence)
135
+                {
116 136
                     $namespace->sequence = $sequence;
117 137
 
118 138
                     $dependency->type->alias = $namespace->fullName();
119 139
                 }
120 140
 
121 141
                 $counters[$namespace->name][$sequence] = $namespace;
122
-            } else {
142
+            }
143
+            else
144
+            {
123 145
                 $counters[$namespace->name] = [$namespace->sequence => $namespace];
124 146
             }
125 147
         }
@@ -130,8 +152,10 @@  discard block
 block discarded – undo
130 152
      */
131 153
     private function getAlreadyImportedNamespace(array $counters, NamespaceEntity $namespace): ?NamespaceEntity
132 154
     {
133
-        foreach ($counters as $counter) {
134
-            if ($counter->equals($namespace)) {
155
+        foreach ($counters as $counter)
156
+        {
157
+            if ($counter->equals($namespace))
158
+            {
135 159
                 return $counter;
136 160
             }
137 161
         }
@@ -146,9 +170,11 @@  discard block
 block discarded – undo
146 170
 
147 171
     private function parseNamespace(string $shortName, string $fullName): NamespaceEntity
148 172
     {
149
-        if (\preg_match("/\d+$/", $shortName, $match)) {
173
+        if (\preg_match("/\d+$/", $shortName, $match))
174
+        {
150 175
             $sequence = (int)$match[0];
151
-            if ($sequence > 0) {
176
+            if ($sequence > 0)
177
+            {
152 178
                 return NamespaceEntity::createWithSequence(
153 179
                     Utils::trimTrailingDigits($shortName, $sequence),
154 180
                     $fullName,
Please login to merge, or discard this patch.
src/Models/src/Reflection/ReflectionEntity.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function getSecured(): mixed
72 72
     {
73
-        if ($this->getProperty('secured', true) === '*') {
73
+        if ($this->getProperty('secured', true) === '*'){
74 74
             return $this->getProperty('secured', true);
75 75
         }
76 76
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
     public function declaredMethods(): array
106 106
     {
107 107
         $methods = [];
108
-        foreach ($this->getMethods() as $method) {
109
-            if ($method->getDeclaringClass()->getName() != $this->getName()) {
108
+        foreach ($this->getMethods() as $method){
109
+            if ($method->getDeclaringClass()->getName() != $this->getName()){
110 110
                 continue;
111 111
             }
112 112
 
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
             self::MUTATOR_ACCESSOR => [],
137 137
         ];
138 138
 
139
-        foreach ((array)$this->getProperty('getters', true) as $field => $filter) {
139
+        foreach ((array)$this->getProperty('getters', true) as $field => $filter){
140 140
             $mutators[self::MUTATOR_GETTER][$field] = $filter;
141 141
         }
142 142
 
143
-        foreach ((array)$this->getProperty('setters', true) as $field => $filter) {
143
+        foreach ((array)$this->getProperty('setters', true) as $field => $filter){
144 144
             $mutators[self::MUTATOR_SETTER][$field] = $filter;
145 145
         }
146 146
 
147
-        foreach ((array)$this->getProperty('accessors', true) as $field => $filter) {
147
+        foreach ((array)$this->getProperty('accessors', true) as $field => $filter){
148 148
             $mutators[self::MUTATOR_ACCESSOR][$field] = $filter;
149 149
         }
150 150
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public function getProperty(string $property, bool $merge = false): mixed
162 162
     {
163
-        if (isset($this->propertyCache[$property])) {
163
+        if (isset($this->propertyCache[$property])){
164 164
             //Property merging and trait events are pretty slow
165 165
             return $this->propertyCache[$property];
166 166
         }
@@ -168,28 +168,28 @@  discard block
 block discarded – undo
168 168
         $properties = $this->reflection->getDefaultProperties();
169 169
         $constants = $this->reflection->getConstants();
170 170
 
171
-        if (isset($properties[$property])) {
171
+        if (isset($properties[$property])){
172 172
             //Read from default value
173 173
             $value = $properties[$property];
174
-        } elseif (isset($constants[\strtoupper($property)])) {
174
+        } elseif (isset($constants[\strtoupper($property)])){
175 175
             //Read from a constant
176 176
             $value = $constants[\strtoupper($property)];
177
-        } else {
177
+        }else{
178 178
             return null;
179 179
         }
180 180
 
181 181
         //Merge with parent value requested
182
-        if ($merge && \is_array($value) && ($parent = $this->parentReflection()) instanceof \Spiral\Models\Reflection\ReflectionEntity) {
182
+        if ($merge && \is_array($value) && ($parent = $this->parentReflection()) instanceof \Spiral\Models\Reflection\ReflectionEntity){
183 183
             $parentValue = $parent->getProperty($property, $merge);
184 184
 
185
-            if (\is_array($parentValue)) {
185
+            if (\is_array($parentValue)){
186 186
                 //Class values prior to parent values
187 187
                 $value = \array_merge($parentValue, $value);
188 188
             }
189 189
         }
190 190
 
191 191
         /** @psalm-suppress TypeDoesNotContainType https://github.com/vimeo/psalm/issues/9489 */
192
-        if (!$this->reflection->isSubclassOf(SchematicEntity::class)) {
192
+        if (!$this->reflection->isSubclassOf(SchematicEntity::class)){
193 193
             return $value;
194 194
         }
195 195
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     {
205 205
         $parentClass = $this->reflection->getParentClass();
206 206
 
207
-        if (!empty($parentClass) && $parentClass->getName() != static::BASE_CLASS) {
207
+        if (!empty($parentClass) && $parentClass->getName() != static::BASE_CLASS){
208 208
             $parent = clone $this;
209 209
             $parent->reflection = $this->getParentClass();
210 210
 
Please login to merge, or discard this patch.
Braces   +30 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,7 +70,8 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function getSecured(): mixed
72 72
     {
73
-        if ($this->getProperty('secured', true) === '*') {
73
+        if ($this->getProperty('secured', true) === '*')
74
+        {
74 75
             return $this->getProperty('secured', true);
75 76
         }
76 77
 
@@ -105,8 +106,10 @@  discard block
 block discarded – undo
105 106
     public function declaredMethods(): array
106 107
     {
107 108
         $methods = [];
108
-        foreach ($this->getMethods() as $method) {
109
-            if ($method->getDeclaringClass()->getName() != $this->getName()) {
109
+        foreach ($this->getMethods() as $method)
110
+        {
111
+            if ($method->getDeclaringClass()->getName() != $this->getName())
112
+            {
110 113
                 continue;
111 114
             }
112 115
 
@@ -136,15 +139,18 @@  discard block
 block discarded – undo
136 139
             self::MUTATOR_ACCESSOR => [],
137 140
         ];
138 141
 
139
-        foreach ((array)$this->getProperty('getters', true) as $field => $filter) {
142
+        foreach ((array)$this->getProperty('getters', true) as $field => $filter)
143
+        {
140 144
             $mutators[self::MUTATOR_GETTER][$field] = $filter;
141 145
         }
142 146
 
143
-        foreach ((array)$this->getProperty('setters', true) as $field => $filter) {
147
+        foreach ((array)$this->getProperty('setters', true) as $field => $filter)
148
+        {
144 149
             $mutators[self::MUTATOR_SETTER][$field] = $filter;
145 150
         }
146 151
 
147
-        foreach ((array)$this->getProperty('accessors', true) as $field => $filter) {
152
+        foreach ((array)$this->getProperty('accessors', true) as $field => $filter)
153
+        {
148 154
             $mutators[self::MUTATOR_ACCESSOR][$field] = $filter;
149 155
         }
150 156
 
@@ -160,7 +166,8 @@  discard block
 block discarded – undo
160 166
      */
161 167
     public function getProperty(string $property, bool $merge = false): mixed
162 168
     {
163
-        if (isset($this->propertyCache[$property])) {
169
+        if (isset($this->propertyCache[$property]))
170
+        {
164 171
             //Property merging and trait events are pretty slow
165 172
             return $this->propertyCache[$property];
166 173
         }
@@ -168,28 +175,36 @@  discard block
 block discarded – undo
168 175
         $properties = $this->reflection->getDefaultProperties();
169 176
         $constants = $this->reflection->getConstants();
170 177
 
171
-        if (isset($properties[$property])) {
178
+        if (isset($properties[$property]))
179
+        {
172 180
             //Read from default value
173 181
             $value = $properties[$property];
174
-        } elseif (isset($constants[\strtoupper($property)])) {
182
+        }
183
+        elseif (isset($constants[\strtoupper($property)]))
184
+        {
175 185
             //Read from a constant
176 186
             $value = $constants[\strtoupper($property)];
177
-        } else {
187
+        }
188
+        else
189
+        {
178 190
             return null;
179 191
         }
180 192
 
181 193
         //Merge with parent value requested
182
-        if ($merge && \is_array($value) && ($parent = $this->parentReflection()) instanceof \Spiral\Models\Reflection\ReflectionEntity) {
194
+        if ($merge && \is_array($value) && ($parent = $this->parentReflection()) instanceof \Spiral\Models\Reflection\ReflectionEntity)
195
+        {
183 196
             $parentValue = $parent->getProperty($property, $merge);
184 197
 
185
-            if (\is_array($parentValue)) {
198
+            if (\is_array($parentValue))
199
+            {
186 200
                 //Class values prior to parent values
187 201
                 $value = \array_merge($parentValue, $value);
188 202
             }
189 203
         }
190 204
 
191 205
         /** @psalm-suppress TypeDoesNotContainType https://github.com/vimeo/psalm/issues/9489 */
192
-        if (!$this->reflection->isSubclassOf(SchematicEntity::class)) {
206
+        if (!$this->reflection->isSubclassOf(SchematicEntity::class))
207
+        {
193 208
             return $value;
194 209
         }
195 210
 
@@ -204,7 +219,8 @@  discard block
 block discarded – undo
204 219
     {
205 220
         $parentClass = $this->reflection->getParentClass();
206 221
 
207
-        if (!empty($parentClass) && $parentClass->getName() != static::BASE_CLASS) {
222
+        if (!empty($parentClass) && $parentClass->getName() != static::BASE_CLASS)
223
+        {
208 224
             $parent = clone $this;
209 225
             $parent->reflection = $this->getParentClass();
210 226
 
Please login to merge, or discard this patch.