Passed
Pull Request — master (#1042)
by Maxim
13:35 queued 04:00
created
src/Stempler/src/Loader/DirectoryLoader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     public function __construct(
15 15
         private readonly string $directory,
16 16
         private readonly string $extension = '.dark.php'
17
-    ) {
17
+    ){
18 18
     }
19 19
 
20 20
     /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             $this->extension
31 31
         );
32 32
 
33
-        if (!\file_exists($filename)) {
33
+        if (!\file_exists($filename)){
34 34
             throw new LoaderException(\sprintf('Unable to load `%s`, no such file', $path));
35 35
         }
36 36
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,8 @@
 block discarded – undo
30 30
             $this->extension
31 31
         );
32 32
 
33
-        if (!\file_exists($filename)) {
33
+        if (!\file_exists($filename))
34
+        {
34 35
             throw new LoaderException(\sprintf('Unable to load `%s`, no such file', $path));
35 36
         }
36 37
 
Please login to merge, or discard this patch.
src/Stempler/src/Loader/StringLoader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
     public function load(string $path): Source
19 19
     {
20
-        if (!\array_key_exists($path, $this->paths)) {
20
+        if (!\array_key_exists($path, $this->paths)){
21 21
             throw new LoaderException(\sprintf('Unable to load path `%s`', $path));
22 22
         }
23 23
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,8 @@
 block discarded – undo
17 17
 
18 18
     public function load(string $path): Source
19 19
     {
20
-        if (!\array_key_exists($path, $this->paths)) {
20
+        if (!\array_key_exists($path, $this->paths))
21
+        {
21 22
             throw new LoaderException(\sprintf('Unable to load path `%s`', $path));
22 23
         }
23 24
 
Please login to merge, or discard this patch.
src/Stempler/src/Builder.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         private readonly LoaderInterface $loader,
36 36
         private readonly Parser $parser = new Parser(),
37 37
         private readonly Compiler $compiler = new Compiler()
38
-    ) {
38
+    ){
39 39
     }
40 40
 
41 41
     public function getLoader(): LoaderInterface
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function compileTemplate(Template $tpl): Result
82 82
     {
83
-        try {
84
-            if (isset($this->visitors[self::STAGE_COMPILE])) {
83
+        try{
84
+            if (isset($this->visitors[self::STAGE_COMPILE])){
85 85
                 $traverser = new Traverser($this->visitors[self::STAGE_COMPILE]);
86 86
                 $tpl = $traverser->traverse([$tpl])[0];
87 87
             }
88 88
 
89 89
             return $this->compiler->compile($tpl);
90
-        } catch (CompilerException $e) {
90
+        }catch (CompilerException $e){
91 91
             throw $this->mapException($e);
92 92
         }
93 93
     }
@@ -100,21 +100,21 @@  discard block
 block discarded – undo
100 100
         $source = $this->loader->load($path);
101 101
         $stream = new StringStream($source->getContent());
102 102
 
103
-        try {
103
+        try{
104 104
             $tpl = $this->parser->withPath($path)->parse($stream);
105 105
             $tpl->setContext(new Context(
106 106
                 new Token(Token::TYPE_RAW, 0, ''),
107 107
                 $path
108 108
             ));
109
-        } catch (ParserException $e) {
109
+        }catch (ParserException $e){
110 110
             throw $this->mapException($e);
111 111
         }
112 112
 
113
-        try {
113
+        try{
114 114
             return $this->process($tpl);
115
-        } catch (ContextExceptionInterface $e) {
115
+        }catch (ContextExceptionInterface $e){
116 116
             throw $this->mapException($e);
117
-        } catch (\Throwable $e) {
117
+        }catch (\Throwable $e){
118 118
             throw $e;
119 119
         }
120 120
     }
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function process(Template $template): Template
126 126
     {
127
-        if (isset($this->visitors[self::STAGE_PREPARE])) {
127
+        if (isset($this->visitors[self::STAGE_PREPARE])){
128 128
             $traverser = new Traverser($this->visitors[self::STAGE_PREPARE]);
129 129
             $template = $traverser->traverse([$template])[0];
130 130
         }
131 131
 
132
-        if (isset($this->visitors[self::STAGE_TRANSFORM])) {
132
+        if (isset($this->visitors[self::STAGE_TRANSFORM])){
133 133
             $traverser = new Traverser($this->visitors[self::STAGE_TRANSFORM]);
134 134
             $template = $traverser->traverse([$template])[0];
135 135
         }
136 136
 
137
-        if (isset($this->visitors[self::STAGE_FINALIZE])) {
137
+        if (isset($this->visitors[self::STAGE_FINALIZE])){
138 138
             $traverser = new Traverser($this->visitors[self::STAGE_FINALIZE]);
139 139
             $template = $traverser->traverse([$template])[0];
140 140
         }
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
      */
148 148
     private function mapException(ContextExceptionInterface $e): ContextExceptionInterface
149 149
     {
150
-        if ($e->getContext()->getPath() === null) {
150
+        if ($e->getContext()->getPath() === null){
151 151
             return $e;
152 152
         }
153 153
 
154
-        try {
154
+        try{
155 155
             $source = $this->loader->load($e->getContext()->getPath());
156
-        } catch (LoaderException) {
156
+        }catch (LoaderException){
157 157
             return $e;
158 158
         }
159 159
 
160
-        if ($source->getFilename() === null) {
160
+        if ($source->getFilename() === null){
161 161
             return $e;
162 162
         }
163 163
 
Please login to merge, or discard this patch.
Braces   +35 added lines, -15 removed lines patch added patch discarded remove patch
@@ -80,14 +80,18 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function compileTemplate(Template $tpl): Result
82 82
     {
83
-        try {
84
-            if (isset($this->visitors[self::STAGE_COMPILE])) {
83
+        try
84
+        {
85
+            if (isset($this->visitors[self::STAGE_COMPILE]))
86
+            {
85 87
                 $traverser = new Traverser($this->visitors[self::STAGE_COMPILE]);
86 88
                 $tpl = $traverser->traverse([$tpl])[0];
87 89
             }
88 90
 
89 91
             return $this->compiler->compile($tpl);
90
-        } catch (CompilerException $e) {
92
+        }
93
+        catch (CompilerException $e)
94
+        {
91 95
             throw $this->mapException($e);
92 96
         }
93 97
     }
@@ -100,21 +104,29 @@  discard block
 block discarded – undo
100 104
         $source = $this->loader->load($path);
101 105
         $stream = new StringStream($source->getContent());
102 106
 
103
-        try {
107
+        try
108
+        {
104 109
             $tpl = $this->parser->withPath($path)->parse($stream);
105 110
             $tpl->setContext(new Context(
106 111
                 new Token(Token::TYPE_RAW, 0, ''),
107 112
                 $path
108 113
             ));
109
-        } catch (ParserException $e) {
114
+        }
115
+        catch (ParserException $e)
116
+        {
110 117
             throw $this->mapException($e);
111 118
         }
112 119
 
113
-        try {
120
+        try
121
+        {
114 122
             return $this->process($tpl);
115
-        } catch (ContextExceptionInterface $e) {
123
+        }
124
+        catch (ContextExceptionInterface $e)
125
+        {
116 126
             throw $this->mapException($e);
117
-        } catch (\Throwable $e) {
127
+        }
128
+        catch (\Throwable $e)
129
+        {
118 130
             throw $e;
119 131
         }
120 132
     }
@@ -124,17 +136,20 @@  discard block
 block discarded – undo
124 136
      */
125 137
     private function process(Template $template): Template
126 138
     {
127
-        if (isset($this->visitors[self::STAGE_PREPARE])) {
139
+        if (isset($this->visitors[self::STAGE_PREPARE]))
140
+        {
128 141
             $traverser = new Traverser($this->visitors[self::STAGE_PREPARE]);
129 142
             $template = $traverser->traverse([$template])[0];
130 143
         }
131 144
 
132
-        if (isset($this->visitors[self::STAGE_TRANSFORM])) {
145
+        if (isset($this->visitors[self::STAGE_TRANSFORM]))
146
+        {
133 147
             $traverser = new Traverser($this->visitors[self::STAGE_TRANSFORM]);
134 148
             $template = $traverser->traverse([$template])[0];
135 149
         }
136 150
 
137
-        if (isset($this->visitors[self::STAGE_FINALIZE])) {
151
+        if (isset($this->visitors[self::STAGE_FINALIZE]))
152
+        {
138 153
             $traverser = new Traverser($this->visitors[self::STAGE_FINALIZE]);
139 154
             $template = $traverser->traverse([$template])[0];
140 155
         }
@@ -147,17 +162,22 @@  discard block
 block discarded – undo
147 162
      */
148 163
     private function mapException(ContextExceptionInterface $e): ContextExceptionInterface
149 164
     {
150
-        if ($e->getContext()->getPath() === null) {
165
+        if ($e->getContext()->getPath() === null)
166
+        {
151 167
             return $e;
152 168
         }
153 169
 
154
-        try {
170
+        try
171
+        {
155 172
             $source = $this->loader->load($e->getContext()->getPath());
156
-        } catch (LoaderException) {
173
+        }
174
+        catch (LoaderException)
175
+        {
157 176
             return $e;
158 177
         }
159 178
 
160
-        if ($source->getFilename() === null) {
179
+        if ($source->getFilename() === null)
180
+        {
161 181
             return $e;
162 182
         }
163 183
 
Please login to merge, or discard this patch.
src/Stempler/src/Node/Block.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
     public function __construct(
26 26
         public ?string $name,
27 27
         Context $context = null
28
-    ) {
28
+    ){
29 29
         $this->context = $context;
30 30
     }
31 31
 
Please login to merge, or discard this patch.
src/Stempler/src/Node/Mixin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     public function __construct(
24 24
         public array $nodes = [],
25 25
         Context $context = null
26
-    ) {
26
+    ){
27 27
         $this->context = $context;
28 28
     }
29 29
 
Please login to merge, or discard this patch.
src/Stempler/src/Node/Aggregate.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public function __construct(
26 26
         Context $context = null,
27 27
         public string $pattern = '*'
28
-    ) {
28
+    ){
29 29
         $this->context = $context;
30 30
     }
31 31
 
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function accepts(string $name): ?string
37 37
     {
38
-        if ($this->pattern === '' || $this->pattern === '*') {
38
+        if ($this->pattern === '' || $this->pattern === '*'){
39 39
             // accept everything
40 40
             return $name;
41 41
         }
42 42
 
43 43
         $conditions = [];
44
-        foreach (\explode(';', $this->pattern) as $condition) {
45
-            if (!\str_contains($condition, ':')) {
44
+        foreach (\explode(';', $this->pattern) as $condition){
45
+            if (!\str_contains($condition, ':')){
46 46
                 //Invalid
47 47
                 continue;
48 48
             }
@@ -51,27 +51,27 @@  discard block
 block discarded – undo
51 51
             $conditions[$option] = $value;
52 52
         }
53 53
 
54
-        if (isset($conditions['include'])) {
54
+        if (isset($conditions['include'])){
55 55
             $include = \explode(',', $conditions['include']);
56
-            if (\in_array($name, $include)) {
56
+            if (\in_array($name, $include)){
57 57
                 return $name;
58 58
             }
59 59
 
60 60
             return null;
61 61
         }
62 62
 
63
-        if (isset($conditions['exclude'])) {
63
+        if (isset($conditions['exclude'])){
64 64
             $exclude = \explode(',', $conditions['exclude']);
65
-            if (\in_array($name, $exclude)) {
65
+            if (\in_array($name, $exclude)){
66 66
                 return null;
67 67
             }
68 68
 
69 69
             return $name;
70 70
         }
71 71
 
72
-        if (isset($conditions['prefix'])) {
72
+        if (isset($conditions['prefix'])){
73 73
             $conditions['prefix'] = \rtrim($conditions['prefix'], ' *');
74
-            if (\str_starts_with($name, $conditions['prefix'])) {
74
+            if (\str_starts_with($name, $conditions['prefix'])){
75 75
                 return substr($name, \strlen($conditions['prefix']));
76 76
             }
77 77
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,14 +35,17 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function accepts(string $name): ?string
37 37
     {
38
-        if ($this->pattern === '' || $this->pattern === '*') {
38
+        if ($this->pattern === '' || $this->pattern === '*')
39
+        {
39 40
             // accept everything
40 41
             return $name;
41 42
         }
42 43
 
43 44
         $conditions = [];
44
-        foreach (\explode(';', $this->pattern) as $condition) {
45
-            if (!\str_contains($condition, ':')) {
45
+        foreach (\explode(';', $this->pattern) as $condition)
46
+        {
47
+            if (!\str_contains($condition, ':'))
48
+            {
46 49
                 //Invalid
47 50
                 continue;
48 51
             }
@@ -51,27 +54,33 @@  discard block
 block discarded – undo
51 54
             $conditions[$option] = $value;
52 55
         }
53 56
 
54
-        if (isset($conditions['include'])) {
57
+        if (isset($conditions['include']))
58
+        {
55 59
             $include = \explode(',', $conditions['include']);
56
-            if (\in_array($name, $include)) {
60
+            if (\in_array($name, $include))
61
+            {
57 62
                 return $name;
58 63
             }
59 64
 
60 65
             return null;
61 66
         }
62 67
 
63
-        if (isset($conditions['exclude'])) {
68
+        if (isset($conditions['exclude']))
69
+        {
64 70
             $exclude = \explode(',', $conditions['exclude']);
65
-            if (\in_array($name, $exclude)) {
71
+            if (\in_array($name, $exclude))
72
+            {
66 73
                 return null;
67 74
             }
68 75
 
69 76
             return $name;
70 77
         }
71 78
 
72
-        if (isset($conditions['prefix'])) {
79
+        if (isset($conditions['prefix']))
80
+        {
73 81
             $conditions['prefix'] = \rtrim($conditions['prefix'], ' *');
74
-            if (\str_starts_with($name, $conditions['prefix'])) {
82
+            if (\str_starts_with($name, $conditions['prefix']))
83
+            {
75 84
                 return substr($name, \strlen($conditions['prefix']));
76 85
             }
77 86
 
Please login to merge, or discard this patch.
src/Stempler/src/Node/HTML/Attr.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
     use ContextTrait;
20 20
 
21 21
     public function __construct(
22
-        public Mixin|string $name,
22
+        public Mixin | string $name,
23 23
         public mixed $value,
24 24
         Context $context = null
25
-    ) {
25
+    ){
26 26
         $this->context = $context;
27 27
     }
28 28
 
Please login to merge, or discard this patch.
src/Stempler/src/Node/HTML/Tag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
     public bool $void = false;
26 26
 
27
-    public Mixin|string|null $name = null;
27
+    public Mixin | string | null $name = null;
28 28
 
29 29
     /** @var Attr[] */
30 30
     public array $attrs = [];
Please login to merge, or discard this patch.
src/Stempler/src/Node/Template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      */
25 25
     public function __construct(
26 26
         public array $nodes = []
27
-    ) {
27
+    ){
28 28
     }
29 29
 
30 30
     public function setContext(Context $context = null): void
Please login to merge, or discard this patch.