Passed
Push — master ( c81bf2...c3afe7 )
by Aleksei
09:08 queued 01:17
created
src/Stempler/tests/Transform/Import/BundleTest.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
         $builder = new Builder($loader);
46 46
 
47 47
         $builder->addVisitor(
48
-            new class implements VisitorInterface {
48
+            new class implements VisitorInterface{
49 49
 
50 50
                 public function enterNode(mixed $node, VisitorContext $ctx): mixed
51 51
                 {
52 52
                     $n = $ctx->getCurrentNode();
53
-                    if ($n instanceof Template) {
53
+                    if ($n instanceof Template){
54 54
                         $import = m::mock(ImportInterface::class);
55 55
                         $import->shouldNotReceive('resolve');
56 56
                         $n->setAttribute(ImportContext::class, [$import]);
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
         $template = new Template();
95 95
 
96 96
         $builder->addVisitor(
97
-            new class($builder, $template) implements VisitorInterface {
97
+            new class($builder, $template) implements VisitorInterface{
98 98
                 public function __construct(
99 99
                     private readonly Builder $builder,
100 100
                     private readonly Template $template,
101
-                ) {}
101
+                ){}
102 102
 
103 103
                 public function enterNode(mixed $node, VisitorContext $ctx): mixed
104 104
                 {
105 105
                     $n = $ctx->getCurrentNode();
106
-                    if ($n instanceof Template) {
106
+                    if ($n instanceof Template){
107 107
                         $import = m::mock(ImportInterface::class);
108 108
                         $import
109 109
                             ->shouldReceive('resolve')
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,12 +45,14 @@  discard block
 block discarded – undo
45 45
         $builder = new Builder($loader);
46 46
 
47 47
         $builder->addVisitor(
48
-            new class implements VisitorInterface {
48
+            new class implements VisitorInterface
49
+            {
49 50
 
50 51
                 public function enterNode(mixed $node, VisitorContext $ctx): mixed
51 52
                 {
52 53
                     $n = $ctx->getCurrentNode();
53
-                    if ($n instanceof Template) {
54
+                    if ($n instanceof Template)
55
+                    {
54 56
                         $import = m::mock(ImportInterface::class);
55 57
                         $import->shouldNotReceive('resolve');
56 58
                         $n->setAttribute(ImportContext::class, [$import]);
@@ -94,16 +96,19 @@  discard block
 block discarded – undo
94 96
         $template = new Template();
95 97
 
96 98
         $builder->addVisitor(
97
-            new class($builder, $template) implements VisitorInterface {
99
+            new class($builder, $template) implements VisitorInterface
100
+            {
98 101
                 public function __construct(
99 102
                     private readonly Builder $builder,
100 103
                     private readonly Template $template,
101
-                ) {}
104
+                ) {
105
+}
102 106
 
103 107
                 public function enterNode(mixed $node, VisitorContext $ctx): mixed
104 108
                 {
105 109
                     $n = $ctx->getCurrentNode();
106
-                    if ($n instanceof Template) {
110
+                    if ($n instanceof Template)
111
+                    {
107 112
                         $import = m::mock(ImportInterface::class);
108 113
                         $import
109 114
                             ->shouldReceive('resolve')
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/Bundle.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
         private string $path,
24 24
         private ?string $prefix = null,
25 25
         ?Context $context = null,
26
-    ) {
26
+    ){
27 27
         $this->context = $context;
28 28
     }
29 29
 
30 30
     public function resolve(Builder $builder, string $name): ?Template
31 31
     {
32
-        if ($this->template === null) {
32
+        if ($this->template === null){
33 33
             $this->template = $builder->load($this->path);
34 34
         }
35 35
 
36 36
         $path = $name;
37
-        if ($this->prefix !== null) {
38
-            if (!TagHelper::hasPrefix($name, $this->prefix)) {
37
+        if ($this->prefix !== null){
38
+            if (!TagHelper::hasPrefix($name, $this->prefix)){
39 39
                 return null;
40 40
             }
41 41
 
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
         }
44 44
 
45 45
         /** @var ImportInterface $import */
46
-        foreach ($this->template->getAttribute(ImportContext::class, []) as $import) {
46
+        foreach ($this->template->getAttribute(ImportContext::class, []) as $import){
47 47
             $tpl = $import->resolve($builder, $path);
48
-            if ($tpl !== null) {
48
+            if ($tpl !== null){
49 49
                 return $tpl;
50 50
             }
51 51
         }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,13 +29,16 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function resolve(Builder $builder, string $name): ?Template
31 31
     {
32
-        if ($this->template === null) {
32
+        if ($this->template === null)
33
+        {
33 34
             $this->template = $builder->load($this->path);
34 35
         }
35 36
 
36 37
         $path = $name;
37
-        if ($this->prefix !== null) {
38
-            if (!TagHelper::hasPrefix($name, $this->prefix)) {
38
+        if ($this->prefix !== null)
39
+        {
40
+            if (!TagHelper::hasPrefix($name, $this->prefix))
41
+            {
39 42
                 return null;
40 43
             }
41 44
 
@@ -43,9 +46,11 @@  discard block
 block discarded – undo
43 46
         }
44 47
 
45 48
         /** @var ImportInterface $import */
46
-        foreach ($this->template->getAttribute(ImportContext::class, []) as $import) {
49
+        foreach ($this->template->getAttribute(ImportContext::class, []) as $import)
50
+        {
47 51
             $tpl = $import->resolve($builder, $path);
48
-            if ($tpl !== null) {
52
+            if ($tpl !== null)
53
+            {
49 54
                 return $tpl;
50 55
             }
51 56
         }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/Directory.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@
 block discarded – undo
29 29
 
30 30
     public function resolve(Builder $builder, string $name): ?Template
31 31
     {
32
-        if (!TagHelper::hasPrefix($name, $this->prefix)) {
32
+        if (!TagHelper::hasPrefix($name, $this->prefix))
33
+        {
33 34
             return null;
34 35
         }
35 36
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@
 block discarded – undo
22 22
         public string $path,
23 23
         ?string $prefix,
24 24
         ?Context $context = null,
25
-    ) {
25
+    ){
26 26
         $this->prefix = $prefix ?? \substr($path, \strrpos($path, '/') + 1);
27 27
         $this->context = $context;
28 28
     }
29 29
 
30 30
     public function resolve(Builder $builder, string $name): ?Template
31 31
     {
32
-        if (!TagHelper::hasPrefix($name, $this->prefix)) {
32
+        if (!TagHelper::hasPrefix($name, $this->prefix)){
33 33
             return null;
34 34
         }
35 35
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/TagHelper.php 2 patches
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@  discard block
 block discarded – undo
19 19
     public static function hasPrefix(string $tag, ?string $prefix): bool
20 20
     {
21 21
         // If no prefix is specified, allow everything
22
-        if ($prefix === null || $prefix === '') {
22
+        if ($prefix === null || $prefix === '')
23
+        {
23 24
             return true;
24 25
         }
25 26
 
@@ -27,11 +28,13 @@  discard block
 block discarded – undo
27 28
         //   1) The prefix itself
28 29
         //   2) The separator
29 30
         //   3) At least one more char after the separator
30
-        if (\strlen($tag) < \strlen($prefix) + 2) {
31
+        if (\strlen($tag) < \strlen($prefix) + 2)
32
+        {
31 33
             return false;
32 34
         }
33 35
 
34
-        if (!\str_starts_with($tag, $prefix)) {
36
+        if (!\str_starts_with($tag, $prefix))
37
+        {
35 38
             return false;
36 39
         }
37 40
 
@@ -40,7 +43,8 @@  discard block
 block discarded – undo
40 43
 
41 44
     public static function stripPrefix(string $tag, ?string $prefix): string
42 45
     {
43
-        if (!self::hasPrefix($tag, $prefix)) {
46
+        if (!self::hasPrefix($tag, $prefix))
47
+        {
44 48
             return $tag;
45 49
         }
46 50
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public static function hasPrefix(string $tag, ?string $prefix): bool
20 20
     {
21 21
         // If no prefix is specified, allow everything
22
-        if ($prefix === null || $prefix === '') {
22
+        if ($prefix === null || $prefix === ''){
23 23
             return true;
24 24
         }
25 25
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
         //   1) The prefix itself
28 28
         //   2) The separator
29 29
         //   3) At least one more char after the separator
30
-        if (\strlen($tag) < \strlen($prefix) + 2) {
30
+        if (\strlen($tag) < \strlen($prefix) + 2){
31 31
             return false;
32 32
         }
33 33
 
34
-        if (!\str_starts_with($tag, $prefix)) {
34
+        if (!\str_starts_with($tag, $prefix)){
35 35
             return false;
36 36
         }
37 37
 
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 
41 41
     public static function stripPrefix(string $tag, ?string $prefix): string
42 42
     {
43
-        if (!self::hasPrefix($tag, $prefix)) {
43
+        if (!self::hasPrefix($tag, $prefix)){
44 44
             return $tag;
45 45
         }
46 46
 
47
-        return \substr($tag, \strlen((string) $prefix) + 1);
47
+        return \substr($tag, \strlen((string)$prefix) + 1);
48 48
     }
49 49
 }
Please login to merge, or discard this patch.
src/Router/tests/UriTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
         $uri = $router->uri('test:id', [
108 108
             'id' => 100,
109
-            'title' => new class implements \Stringable {
109
+            'title' => new class implements \Stringable{
110 110
                 public function __toString()
111 111
                 {
112 112
                     return 'hello-world';
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         $uriHandler->setStrict(true);
202 202
         $route = $route->withUriHandler($uriHandler);
203 203
 
204
-        self::assertSame($expected, (string) $route->uri($params));
204
+        self::assertSame($expected, (string)$route->uri($params));
205 205
     }
206 206
 
207 207
     #[DataProvider('provideSegmentInDifferentLanguages')]
Please login to merge, or discard this patch.
src/Telemetry/src/Monolog/TelemetryProcessor.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
 {
14 14
     public function __construct(
15 15
         private readonly ContainerInterface $container,
16
-    ) {}
16
+    ){}
17 17
 
18 18
     /**
19 19
      * @psalm-suppress InvalidReturnType
20 20
      * @psalm-suppress InvalidReturnStatement
21 21
      */
22
-    public function __invoke(LogRecord|array $record): array|LogRecord
22
+    public function __invoke(LogRecord | array $record): array | LogRecord
23 23
     {
24 24
         $tracer = $this->container->get(TracerInterface::class);
25 25
         \assert($tracer instanceof TracerInterface);
26 26
 
27 27
         $context = $tracer->getContext();
28 28
 
29
-        if (!empty($context)) {
29
+        if (!empty($context)){
30 30
             $record['extra']['telemetry'] = $context;
31 31
         }
32 32
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,8 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function __construct(
15 15
         private readonly ContainerInterface $container,
16
-    ) {}
16
+    ) {
17
+}
17 18
 
18 19
     /**
19 20
      * @psalm-suppress InvalidReturnType
@@ -26,7 +27,8 @@  discard block
 block discarded – undo
26 27
 
27 28
         $context = $tracer->getContext();
28 29
 
29
-        if (!empty($context)) {
30
+        if (!empty($context))
31
+        {
30 32
             $record['extra']['telemetry'] = $context;
31 33
         }
32 34
 
Please login to merge, or discard this patch.
src/Telemetry/tests/Monolog/TelemetryProcessorTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             ],
73 73
         ];
74 74
 
75
-        if (!\class_exists(LogRecord::class)) {
75
+        if (!\class_exists(LogRecord::class)){
76 76
             return;
77 77
         }
78 78
 
@@ -127,6 +127,6 @@  discard block
 block discarded – undo
127 127
 
128 128
         $record = $processor->__invoke($record);
129 129
 
130
-        self::assertSame($expected, (array) $record);
130
+        self::assertSame($expected, (array)$record);
131 131
     }
132 132
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,8 @@
 block discarded – undo
72 72
             ],
73 73
         ];
74 74
 
75
-        if (!\class_exists(LogRecord::class)) {
75
+        if (!\class_exists(LogRecord::class))
76
+        {
76 77
             return;
77 78
         }
78 79
 
Please login to merge, or discard this patch.
src/Cache/src/CacheRepository.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         protected CacheInterface $storage,
26 26
         protected ?EventDispatcherInterface $dispatcher = null,
27 27
         protected ?string $prefix = null,
28
-    ) {}
28
+    ){}
29 29
 
30 30
     public function get(string $key, mixed $default = null): mixed
31 31
     {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
         $value = $this->storage->get($key);
37 37
 
38
-        if ($value === null) {
38
+        if ($value === null){
39 39
             $this->dispatcher?->dispatch(new CacheMissed($key));
40 40
 
41 41
             return $default;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         return $value;
47 47
     }
48 48
 
49
-    public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool
49
+    public function set(string $key, mixed $value, \DateInterval | int | null $ttl = null): bool
50 50
     {
51 51
         $key = $this->resolveKey($key);
52 52
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     {
90 90
         $array = [];
91 91
         // Resolve keys and dispatch events
92
-        foreach ($keys as $key) {
92
+        foreach ($keys as $key){
93 93
             $key = $this->resolveKey($key);
94 94
             $this->dispatcher?->dispatch(new CacheRetrieving($key));
95 95
             // Fill resulting array with default values
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
         // If no dispatcher is set, we can skip the loop with events
100 100
         // to save some CPU cycles
101 101
         $keys = \array_keys($array);
102
-        if ($this->dispatcher === null) {
102
+        if ($this->dispatcher === null){
103 103
             return $this->storage->getMultiple($keys, $default);
104 104
         }
105 105
 
106 106
         $result = $this->storage->getMultiple($keys);
107 107
 
108
-        foreach ($result as $key => $value) {
109
-            if ($value === null) {
108
+        foreach ($result as $key => $value){
109
+            if ($value === null){
110 110
                 $this->dispatcher->dispatch(new CacheMissed($key));
111
-            } else {
111
+            }else{
112 112
                 // Replace default value with actual value in the resulting array
113 113
                 $array[$key] = $value;
114 114
                 $this->dispatcher->dispatch(new CacheHit($key, $value));
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
         return $array;
119 119
     }
120 120
 
121
-    public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool
121
+    public function setMultiple(iterable $values, \DateInterval | int | null $ttl = null): bool
122 122
     {
123 123
         $dispatcher = $this->dispatcher;
124 124
         $array = [];
125 125
         // Resolve keys and dispatch events
126
-        foreach ($values as $key => $value) {
126
+        foreach ($values as $key => $value){
127 127
             $key = $this->resolveKey($key);
128 128
             $dispatcher?->dispatch(new KeyWriting($key, $value));
129 129
             $array[$key] = $value;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
         $array = [];
150 150
         // Resolve keys and dispatch events
151
-        foreach ($keys as $key) {
151
+        foreach ($keys as $key){
152 152
             $key = $this->resolveKey($key);
153 153
             $dispatcher?->dispatch(new KeyDeleting($key));
154 154
             $array[] = $key;
@@ -179,6 +179,6 @@  discard block
 block discarded – undo
179 179
 
180 180
     private function resolveKey(string $key): string
181 181
     {
182
-        return $this->prefix . $key;
182
+        return $this->prefix.$key;
183 183
     }
184 184
 }
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
         protected CacheInterface $storage,
26 26
         protected ?EventDispatcherInterface $dispatcher = null,
27 27
         protected ?string $prefix = null,
28
-    ) {}
28
+    ) {
29
+}
29 30
 
30 31
     public function get(string $key, mixed $default = null): mixed
31 32
     {
@@ -35,7 +36,8 @@  discard block
 block discarded – undo
35 36
 
36 37
         $value = $this->storage->get($key);
37 38
 
38
-        if ($value === null) {
39
+        if ($value === null)
40
+        {
39 41
             $this->dispatcher?->dispatch(new CacheMissed($key));
40 42
 
41 43
             return $default;
@@ -89,7 +91,8 @@  discard block
 block discarded – undo
89 91
     {
90 92
         $array = [];
91 93
         // Resolve keys and dispatch events
92
-        foreach ($keys as $key) {
94
+        foreach ($keys as $key)
95
+        {
93 96
             $key = $this->resolveKey($key);
94 97
             $this->dispatcher?->dispatch(new CacheRetrieving($key));
95 98
             // Fill resulting array with default values
@@ -99,16 +102,21 @@  discard block
 block discarded – undo
99 102
         // If no dispatcher is set, we can skip the loop with events
100 103
         // to save some CPU cycles
101 104
         $keys = \array_keys($array);
102
-        if ($this->dispatcher === null) {
105
+        if ($this->dispatcher === null)
106
+        {
103 107
             return $this->storage->getMultiple($keys, $default);
104 108
         }
105 109
 
106 110
         $result = $this->storage->getMultiple($keys);
107 111
 
108
-        foreach ($result as $key => $value) {
109
-            if ($value === null) {
112
+        foreach ($result as $key => $value)
113
+        {
114
+            if ($value === null)
115
+            {
110 116
                 $this->dispatcher->dispatch(new CacheMissed($key));
111
-            } else {
117
+            }
118
+            else
119
+            {
112 120
                 // Replace default value with actual value in the resulting array
113 121
                 $array[$key] = $value;
114 122
                 $this->dispatcher->dispatch(new CacheHit($key, $value));
@@ -123,7 +131,8 @@  discard block
 block discarded – undo
123 131
         $dispatcher = $this->dispatcher;
124 132
         $array = [];
125 133
         // Resolve keys and dispatch events
126
-        foreach ($values as $key => $value) {
134
+        foreach ($values as $key => $value)
135
+        {
127 136
             $key = $this->resolveKey($key);
128 137
             $dispatcher?->dispatch(new KeyWriting($key, $value));
129 138
             $array[$key] = $value;
@@ -148,7 +157,8 @@  discard block
 block discarded – undo
148 157
 
149 158
         $array = [];
150 159
         // Resolve keys and dispatch events
151
-        foreach ($keys as $key) {
160
+        foreach ($keys as $key)
161
+        {
152 162
             $key = $this->resolveKey($key);
153 163
             $dispatcher?->dispatch(new KeyDeleting($key));
154 164
             $array[] = $key;
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/Dynamic/DirectiveGrammar.php 2 patches
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -39,39 +39,39 @@  discard block
 block discarded – undo
39 39
         $this->body = null;
40 40
         $hasWhitespace = false;
41 41
 
42
-        while ($n = $src->next()) {
43
-            if (!$n instanceof Byte) {
42
+        while ($n = $src->next()){
43
+            if (!$n instanceof Byte){
44 44
                 // no other grammars are allowed
45 45
                 break;
46 46
             }
47 47
 
48
-            switch ($n->char) {
48
+            switch ($n->char){
49 49
                 case '(':
50 50
                     $this->flushName();
51 51
                     $this->tokens[] = new Token(DynamicGrammar::TYPE_BODY_OPEN, $n->offset, $n->char);
52 52
 
53 53
                     return $this->parseBody($src);
54 54
                 default:
55
-                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) {
55
+                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)){
56 56
                         $hasWhitespace = true;
57
-                        if ($this->name !== []) {
57
+                        if ($this->name !== []){
58 58
                             $this->flushName();
59 59
                             $this->tokens[] = new Token(DynamicGrammar::TYPE_WHITESPACE, $n->offset, $n->char);
60 60
                             break;
61 61
                         }
62 62
 
63
-                        if ($this->getLastToken()->type === DynamicGrammar::TYPE_WHITESPACE) {
63
+                        if ($this->getLastToken()->type === DynamicGrammar::TYPE_WHITESPACE){
64 64
                             $this->getLastToken()->content .= $n->char;
65 65
                             break;
66 66
                         }
67 67
 
68 68
                         // invalid directive
69 69
                         return false;
70
-                    } elseif ($hasWhitespace) {
70
+                    } elseif ($hasWhitespace){
71 71
                         return $this->finalize();
72 72
                     }
73 73
 
74
-                    if (!\preg_match(self::REGEXP_KEYWORD, $n->char)) {
74
+                    if (!\preg_match(self::REGEXP_KEYWORD, $n->char)){
75 75
                         $this->flushName();
76 76
 
77 77
                         return $this->finalize();
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getIterator(): \Generator
95 95
     {
96
-        if ($this->tokens === []) {
96
+        if ($this->tokens === []){
97 97
             throw new \LogicException('Directive not parsed');
98 98
         }
99 99
 
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getKeyword(): string
115 115
     {
116
-        foreach ($this->tokens as $token) {
117
-            if ($token->type === DynamicGrammar::TYPE_KEYWORD) {
116
+        foreach ($this->tokens as $token){
117
+            if ($token->type === DynamicGrammar::TYPE_KEYWORD){
118 118
                 return $token->content;
119 119
             }
120 120
         }
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function getBody(): ?string
129 129
     {
130
-        foreach ($this->tokens as $token) {
131
-            if ($token->type === DynamicGrammar::TYPE_BODY) {
130
+        foreach ($this->tokens as $token){
131
+            if ($token->type === DynamicGrammar::TYPE_BODY){
132 132
                 return $token->content;
133 133
             }
134 134
         }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     private function flushName(): void
143 143
     {
144
-        if ($this->name === []) {
144
+        if ($this->name === []){
145 145
             return;
146 146
         }
147 147
 
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
         $this->body = [];
160 160
         $level = 1;
161 161
 
162
-        while ($nn = $src->next()) {
163
-            if (!$nn instanceof Byte) {
162
+        while ($nn = $src->next()){
163
+            if (!$nn instanceof Byte){
164 164
                 $this->flushBody();
165 165
                 return $this->finalize();
166 166
             }
167 167
 
168
-            if (\in_array($nn->char, ['"', '"'])) {
168
+            if (\in_array($nn->char, ['"', '"'])){
169 169
                 $this->body[] = $nn;
170
-                while ($nnn = $src->next()) {
170
+                while ($nnn = $src->next()){
171 171
                     $this->body[] = $nnn;
172
-                    if ($nnn instanceof Byte && $nnn->char === $nn->char) {
172
+                    if ($nnn instanceof Byte && $nnn->char === $nn->char){
173 173
                         break;
174 174
                     }
175 175
                 }
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
 
179 179
             $this->body[] = $nn;
180 180
 
181
-            if ($nn->char === '(') {
181
+            if ($nn->char === '('){
182 182
                 $level++;
183 183
                 continue;
184 184
             }
185 185
 
186
-            if ($nn->char === ')') {
186
+            if ($nn->char === ')'){
187 187
                 $level--;
188 188
 
189
-                if ($level === 0) {
189
+                if ($level === 0){
190 190
                     $n = \array_pop($this->body);
191 191
 
192 192
                     $this->flushBody();
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     private function flushBody(): void
207 207
     {
208
-        if ($this->body === []) {
208
+        if ($this->body === []){
209 209
             return;
210 210
         }
211 211
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
     private function getLastToken(): Token
217 217
     {
218
-        if ($this->tokens === []) {
218
+        if ($this->tokens === []){
219 219
             throw new \LogicException('Directive not parsed');
220 220
         }
221 221
 
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 
232 232
         // A directive must have at least one keyword
233 233
         // Without it, it's just a char
234
-        if (\count($tokens) === 1 && $tokens[0]->content === self::DIRECTIVE_CHAR) {
234
+        if (\count($tokens) === 1 && $tokens[0]->content === self::DIRECTIVE_CHAR){
235 235
             return false;
236 236
         }
237 237
 
238
-        foreach (\array_reverse($tokens, true) as $i => $t) {
239
-            if ($t->type !== DynamicGrammar::TYPE_WHITESPACE) {
238
+        foreach (\array_reverse($tokens, true) as $i => $t){
239
+            if ($t->type !== DynamicGrammar::TYPE_WHITESPACE){
240 240
                 break;
241 241
             }
242 242
 
@@ -244,18 +244,18 @@  discard block
 block discarded – undo
244 244
         }
245 245
 
246 246
         $body = null;
247
-        foreach ($tokens as $t) {
248
-            if ($t->type === DynamicGrammar::TYPE_BODY_OPEN) {
247
+        foreach ($tokens as $t){
248
+            if ($t->type === DynamicGrammar::TYPE_BODY_OPEN){
249 249
                 $body = false;
250 250
                 continue;
251 251
             }
252 252
 
253
-            if ($t->type === DynamicGrammar::TYPE_BODY_CLOSE) {
253
+            if ($t->type === DynamicGrammar::TYPE_BODY_CLOSE){
254 254
                 $body = null;
255 255
             }
256 256
         }
257 257
 
258
-        if ($body !== null) {
258
+        if ($body !== null){
259 259
             return false;
260 260
         }
261 261
 
Please login to merge, or discard this patch.
Braces   +63 added lines, -31 removed lines patch added patch discarded remove patch
@@ -39,39 +39,48 @@  discard block
 block discarded – undo
39 39
         $this->body = null;
40 40
         $hasWhitespace = false;
41 41
 
42
-        while ($n = $src->next()) {
43
-            if (!$n instanceof Byte) {
42
+        while ($n = $src->next())
43
+        {
44
+            if (!$n instanceof Byte)
45
+            {
44 46
                 // no other grammars are allowed
45 47
                 break;
46 48
             }
47 49
 
48
-            switch ($n->char) {
50
+            switch ($n->char)
51
+            {
49 52
                 case '(':
50 53
                     $this->flushName();
51 54
                     $this->tokens[] = new Token(DynamicGrammar::TYPE_BODY_OPEN, $n->offset, $n->char);
52 55
 
53 56
                     return $this->parseBody($src);
54 57
                 default:
55
-                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) {
58
+                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char))
59
+                    {
56 60
                         $hasWhitespace = true;
57
-                        if ($this->name !== []) {
61
+                        if ($this->name !== [])
62
+                        {
58 63
                             $this->flushName();
59 64
                             $this->tokens[] = new Token(DynamicGrammar::TYPE_WHITESPACE, $n->offset, $n->char);
60 65
                             break;
61 66
                         }
62 67
 
63
-                        if ($this->getLastToken()->type === DynamicGrammar::TYPE_WHITESPACE) {
68
+                        if ($this->getLastToken()->type === DynamicGrammar::TYPE_WHITESPACE)
69
+                        {
64 70
                             $this->getLastToken()->content .= $n->char;
65 71
                             break;
66 72
                         }
67 73
 
68 74
                         // invalid directive
69 75
                         return false;
70
-                    } elseif ($hasWhitespace) {
76
+                    }
77
+                    elseif ($hasWhitespace)
78
+                    {
71 79
                         return $this->finalize();
72 80
                     }
73 81
 
74
-                    if (!\preg_match(self::REGEXP_KEYWORD, $n->char)) {
82
+                    if (!\preg_match(self::REGEXP_KEYWORD, $n->char))
83
+                    {
75 84
                         $this->flushName();
76 85
 
77 86
                         return $this->finalize();
@@ -93,7 +102,8 @@  discard block
 block discarded – undo
93 102
      */
94 103
     public function getIterator(): \Generator
95 104
     {
96
-        if ($this->tokens === []) {
105
+        if ($this->tokens === [])
106
+        {
97 107
             throw new \LogicException('Directive not parsed');
98 108
         }
99 109
 
@@ -113,8 +123,10 @@  discard block
 block discarded – undo
113 123
      */
114 124
     public function getKeyword(): string
115 125
     {
116
-        foreach ($this->tokens as $token) {
117
-            if ($token->type === DynamicGrammar::TYPE_KEYWORD) {
126
+        foreach ($this->tokens as $token)
127
+        {
128
+            if ($token->type === DynamicGrammar::TYPE_KEYWORD)
129
+            {
118 130
                 return $token->content;
119 131
             }
120 132
         }
@@ -127,8 +139,10 @@  discard block
 block discarded – undo
127 139
      */
128 140
     public function getBody(): ?string
129 141
     {
130
-        foreach ($this->tokens as $token) {
131
-            if ($token->type === DynamicGrammar::TYPE_BODY) {
142
+        foreach ($this->tokens as $token)
143
+        {
144
+            if ($token->type === DynamicGrammar::TYPE_BODY)
145
+            {
132 146
                 return $token->content;
133 147
             }
134 148
         }
@@ -141,7 +155,8 @@  discard block
 block discarded – undo
141 155
      */
142 156
     private function flushName(): void
143 157
     {
144
-        if ($this->name === []) {
158
+        if ($this->name === [])
159
+        {
145 160
             return;
146 161
         }
147 162
 
@@ -159,17 +174,22 @@  discard block
 block discarded – undo
159 174
         $this->body = [];
160 175
         $level = 1;
161 176
 
162
-        while ($nn = $src->next()) {
163
-            if (!$nn instanceof Byte) {
177
+        while ($nn = $src->next())
178
+        {
179
+            if (!$nn instanceof Byte)
180
+            {
164 181
                 $this->flushBody();
165 182
                 return $this->finalize();
166 183
             }
167 184
 
168
-            if (\in_array($nn->char, ['"', '"'])) {
185
+            if (\in_array($nn->char, ['"', '"']))
186
+            {
169 187
                 $this->body[] = $nn;
170
-                while ($nnn = $src->next()) {
188
+                while ($nnn = $src->next())
189
+                {
171 190
                     $this->body[] = $nnn;
172
-                    if ($nnn instanceof Byte && $nnn->char === $nn->char) {
191
+                    if ($nnn instanceof Byte && $nnn->char === $nn->char)
192
+                    {
173 193
                         break;
174 194
                     }
175 195
                 }
@@ -178,15 +198,18 @@  discard block
 block discarded – undo
178 198
 
179 199
             $this->body[] = $nn;
180 200
 
181
-            if ($nn->char === '(') {
201
+            if ($nn->char === '(')
202
+            {
182 203
                 $level++;
183 204
                 continue;
184 205
             }
185 206
 
186
-            if ($nn->char === ')') {
207
+            if ($nn->char === ')')
208
+            {
187 209
                 $level--;
188 210
 
189
-                if ($level === 0) {
211
+                if ($level === 0)
212
+                {
190 213
                     $n = \array_pop($this->body);
191 214
 
192 215
                     $this->flushBody();
@@ -205,7 +228,8 @@  discard block
 block discarded – undo
205 228
      */
206 229
     private function flushBody(): void
207 230
     {
208
-        if ($this->body === []) {
231
+        if ($this->body === [])
232
+        {
209 233
             return;
210 234
         }
211 235
 
@@ -215,7 +239,8 @@  discard block
 block discarded – undo
215 239
 
216 240
     private function getLastToken(): Token
217 241
     {
218
-        if ($this->tokens === []) {
242
+        if ($this->tokens === [])
243
+        {
219 244
             throw new \LogicException('Directive not parsed');
220 245
         }
221 246
 
@@ -231,12 +256,15 @@  discard block
 block discarded – undo
231 256
 
232 257
         // A directive must have at least one keyword
233 258
         // Without it, it's just a char
234
-        if (\count($tokens) === 1 && $tokens[0]->content === self::DIRECTIVE_CHAR) {
259
+        if (\count($tokens) === 1 && $tokens[0]->content === self::DIRECTIVE_CHAR)
260
+        {
235 261
             return false;
236 262
         }
237 263
 
238
-        foreach (\array_reverse($tokens, true) as $i => $t) {
239
-            if ($t->type !== DynamicGrammar::TYPE_WHITESPACE) {
264
+        foreach (\array_reverse($tokens, true) as $i => $t)
265
+        {
266
+            if ($t->type !== DynamicGrammar::TYPE_WHITESPACE)
267
+            {
240 268
                 break;
241 269
             }
242 270
 
@@ -244,18 +272,22 @@  discard block
 block discarded – undo
244 272
         }
245 273
 
246 274
         $body = null;
247
-        foreach ($tokens as $t) {
248
-            if ($t->type === DynamicGrammar::TYPE_BODY_OPEN) {
275
+        foreach ($tokens as $t)
276
+        {
277
+            if ($t->type === DynamicGrammar::TYPE_BODY_OPEN)
278
+            {
249 279
                 $body = false;
250 280
                 continue;
251 281
             }
252 282
 
253
-            if ($t->type === DynamicGrammar::TYPE_BODY_CLOSE) {
283
+            if ($t->type === DynamicGrammar::TYPE_BODY_CLOSE)
284
+            {
254 285
                 $body = null;
255 286
             }
256 287
         }
257 288
 
258
-        if ($body !== null) {
289
+        if ($body !== null)
290
+        {
259 291
             return false;
260 292
         }
261 293
 
Please login to merge, or discard this patch.