Passed
Pull Request — master (#656)
by Abdul Malik
14:10 queued 04:21
created
src/Stempler/src/Node/Aggregate.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function accepts(string $name): ?string
51 51
     {
52
-        if ($this->pattern === '' || $this->pattern === '*') {
52
+        if ($this->pattern === '' || $this->pattern === '*'){
53 53
             // accept everything
54 54
             return $name;
55 55
         }
56 56
 
57 57
         $conditions = [];
58
-        foreach (explode(';', $this->pattern) as $condition) {
59
-            if (strpos($condition, ':') === false) {
58
+        foreach (explode(';', $this->pattern) as $condition){
59
+            if (strpos($condition, ':') === false){
60 60
                 //Invalid
61 61
                 continue;
62 62
             }
@@ -65,27 +65,27 @@  discard block
 block discarded – undo
65 65
             $conditions[$option] = $value;
66 66
         }
67 67
 
68
-        if (isset($conditions['include'])) {
68
+        if (isset($conditions['include'])){
69 69
             $include = explode(',', $conditions['include']);
70
-            if (in_array($name, $include)) {
70
+            if (in_array($name, $include)){
71 71
                 return $name;
72 72
             }
73 73
 
74 74
             return null;
75 75
         }
76 76
 
77
-        if (isset($conditions['exclude'])) {
77
+        if (isset($conditions['exclude'])){
78 78
             $exclude = explode(',', $conditions['exclude']);
79
-            if (in_array($name, $exclude)) {
79
+            if (in_array($name, $exclude)){
80 80
                 return null;
81 81
             }
82 82
 
83 83
             return $name;
84 84
         }
85 85
 
86
-        if (isset($conditions['prefix'])) {
86
+        if (isset($conditions['prefix'])){
87 87
             $conditions['prefix'] = rtrim($conditions['prefix'], ' *');
88
-            if (strpos($name, $conditions['prefix']) === 0) {
88
+            if (strpos($name, $conditions['prefix']) === 0){
89 89
                 return substr($name, strlen($conditions['prefix']));
90 90
             }
91 91
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -49,14 +49,17 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function accepts(string $name): ?string
51 51
     {
52
-        if ($this->pattern === '' || $this->pattern === '*') {
52
+        if ($this->pattern === '' || $this->pattern === '*')
53
+        {
53 54
             // accept everything
54 55
             return $name;
55 56
         }
56 57
 
57 58
         $conditions = [];
58
-        foreach (explode(';', $this->pattern) as $condition) {
59
-            if (strpos($condition, ':') === false) {
59
+        foreach (explode(';', $this->pattern) as $condition)
60
+        {
61
+            if (strpos($condition, ':') === false)
62
+            {
60 63
                 //Invalid
61 64
                 continue;
62 65
             }
@@ -65,27 +68,33 @@  discard block
 block discarded – undo
65 68
             $conditions[$option] = $value;
66 69
         }
67 70
 
68
-        if (isset($conditions['include'])) {
71
+        if (isset($conditions['include']))
72
+        {
69 73
             $include = explode(',', $conditions['include']);
70
-            if (in_array($name, $include)) {
74
+            if (in_array($name, $include))
75
+            {
71 76
                 return $name;
72 77
             }
73 78
 
74 79
             return null;
75 80
         }
76 81
 
77
-        if (isset($conditions['exclude'])) {
82
+        if (isset($conditions['exclude']))
83
+        {
78 84
             $exclude = explode(',', $conditions['exclude']);
79
-            if (in_array($name, $exclude)) {
85
+            if (in_array($name, $exclude))
86
+            {
80 87
                 return null;
81 88
             }
82 89
 
83 90
             return $name;
84 91
         }
85 92
 
86
-        if (isset($conditions['prefix'])) {
93
+        if (isset($conditions['prefix']))
94
+        {
87 95
             $conditions['prefix'] = rtrim($conditions['prefix'], ' *');
88
-            if (strpos($name, $conditions['prefix']) === 0) {
96
+            if (strpos($name, $conditions['prefix']) === 0)
97
+            {
89 98
                 return substr($name, strlen($conditions['prefix']));
90 99
             }
91 100
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/StringStream.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
      */
54 54
     public function peak(): ?string
55 55
     {
56
-        if ($this->offset + 1 > $this->length) {
56
+        if ($this->offset + 1 > $this->length){
57 57
             return null;
58 58
         }
59 59
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,8 @@
 block discarded – undo
53 53
      */
54 54
     public function peak(): ?string
55 55
     {
56
-        if ($this->offset + 1 > $this->length) {
56
+        if ($this->offset + 1 > $this->length)
57
+        {
57 58
             return null;
58 59
         }
59 60
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/RawGrammar.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
         $buffer = null;
28 28
         $bufferOffset = 0;
29 29
 
30
-        foreach ($src as $n) {
31
-            if ($n instanceof Byte) {
32
-                if ($buffer === null) {
30
+        foreach ($src as $n){
31
+            if ($n instanceof Byte){
32
+                if ($buffer === null){
33 33
                     $buffer = '';
34 34
                     $bufferOffset = $n->offset;
35 35
                 }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
                 continue;
39 39
             }
40 40
 
41
-            if ($buffer !== null) {
41
+            if ($buffer !== null){
42 42
                 yield new Token(Token::TYPE_RAW, $bufferOffset, $buffer);
43 43
                 $buffer = null;
44 44
             }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             yield $n;
47 47
         }
48 48
 
49
-        if ($buffer !== null) {
49
+        if ($buffer !== null){
50 50
             yield new Token(Token::TYPE_RAW, $bufferOffset, $buffer);
51 51
         }
52 52
     }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,9 +27,12 @@  discard block
 block discarded – undo
27 27
         $buffer = null;
28 28
         $bufferOffset = 0;
29 29
 
30
-        foreach ($src as $n) {
31
-            if ($n instanceof Byte) {
32
-                if ($buffer === null) {
30
+        foreach ($src as $n)
31
+        {
32
+            if ($n instanceof Byte)
33
+            {
34
+                if ($buffer === null)
35
+                {
33 36
                     $buffer = '';
34 37
                     $bufferOffset = $n->offset;
35 38
                 }
@@ -38,7 +41,8 @@  discard block
 block discarded – undo
38 41
                 continue;
39 42
             }
40 43
 
41
-            if ($buffer !== null) {
44
+            if ($buffer !== null)
45
+            {
42 46
                 yield new Token(Token::TYPE_RAW, $bufferOffset, $buffer);
43 47
                 $buffer = null;
44 48
             }
@@ -46,7 +50,8 @@  discard block
 block discarded – undo
46 50
             yield $n;
47 51
         }
48 52
 
49
-        if ($buffer !== null) {
53
+        if ($buffer !== null)
54
+        {
50 55
             yield new Token(Token::TYPE_RAW, $bufferOffset, $buffer);
51 56
         }
52 57
     }
Please login to merge, or discard this patch.
src/Stempler/src/Parser/Syntax/Traits/MixinTrait.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@
 block discarded – undo
26 26
      */
27 27
     private function parseToken(Parser $parser, Token $token)
28 28
     {
29
-        if ($token->tokens === []) {
30
-            if ($token->type === Token::TYPE_RAW) {
29
+        if ($token->tokens === []){
30
+            if ($token->type === Token::TYPE_RAW){
31 31
                 return new Raw($token->content);
32 32
             }
33 33
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,10 @@
 block discarded – undo
26 26
      */
27 27
     private function parseToken(Parser $parser, Token $token)
28 28
     {
29
-        if ($token->tokens === []) {
30
-            if ($token->type === Token::TYPE_RAW) {
29
+        if ($token->tokens === [])
30
+        {
31
+            if ($token->type === Token::TYPE_RAW)
32
+            {
31 33
                 return new Raw($token->content);
32 34
             }
33 35
 
Please login to merge, or discard this patch.
src/Stempler/src/Parser.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $parser->path = $path;
59 59
         $parser->lexer = clone $this->lexer;
60 60
 
61
-        foreach ($parser->syntax as $grammar => $stx) {
61
+        foreach ($parser->syntax as $grammar => $stx){
62 62
             $parser->syntax[$grammar] = clone $stx;
63 63
         }
64 64
 
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
     {
96 96
         $template = new Template();
97 97
 
98
-        try {
98
+        try{
99 99
             $this->parseTokens(
100 100
                 new Assembler($template, 'nodes'),
101 101
                 $this->lexer->parse($stream)
102 102
             );
103
-        } catch (SyntaxException $e) {
103
+        }catch (SyntaxException $e){
104 104
             throw new ParserException(
105 105
                 $e->getMessage(),
106 106
                 new Context($e->getToken(), $this->getPath()),
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
         $node = $asm->getNode();
123 123
 
124 124
         $syntax = [];
125
-        foreach ($this->syntax as $grammar => $stx) {
125
+        foreach ($this->syntax as $grammar => $stx){
126 126
             $syntax[$grammar] = clone $stx;
127 127
         }
128 128
 
129
-        foreach ($tokens as $token) {
130
-            if (!isset($syntax[$token->grammar])) {
129
+        foreach ($tokens as $token){
130
+            if (!isset($syntax[$token->grammar])){
131 131
                 throw new SyntaxException('Undefined token', $token);
132 132
             }
133 133
 
134 134
             $syntax[$token->grammar]->handle($this, $asm, $token);
135 135
         }
136 136
 
137
-        if ($asm->getNode() !== $node) {
137
+        if ($asm->getNode() !== $node){
138 138
             throw new SyntaxException(
139
-                'Invalid node hierarchy, unclosed ' . $asm->getStackPath(),
139
+                'Invalid node hierarchy, unclosed '.$asm->getStackPath(),
140 140
                 $asm->getNode()->getContext()->getToken()
141 141
             );
142 142
         }
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -58,7 +58,8 @@  discard block
 block discarded – undo
58 58
         $parser->path = $path;
59 59
         $parser->lexer = clone $this->lexer;
60 60
 
61
-        foreach ($parser->syntax as $grammar => $stx) {
61
+        foreach ($parser->syntax as $grammar => $stx)
62
+        {
62 63
             $parser->syntax[$grammar] = clone $stx;
63 64
         }
64 65
 
@@ -95,12 +96,15 @@  discard block
 block discarded – undo
95 96
     {
96 97
         $template = new Template();
97 98
 
98
-        try {
99
+        try
100
+        {
99 101
             $this->parseTokens(
100 102
                 new Assembler($template, 'nodes'),
101 103
                 $this->lexer->parse($stream)
102 104
             );
103
-        } catch (SyntaxException $e) {
105
+        }
106
+        catch (SyntaxException $e)
107
+        {
104 108
             throw new ParserException(
105 109
                 $e->getMessage(),
106 110
                 new Context($e->getToken(), $this->getPath()),
@@ -122,19 +126,23 @@  discard block
 block discarded – undo
122 126
         $node = $asm->getNode();
123 127
 
124 128
         $syntax = [];
125
-        foreach ($this->syntax as $grammar => $stx) {
129
+        foreach ($this->syntax as $grammar => $stx)
130
+        {
126 131
             $syntax[$grammar] = clone $stx;
127 132
         }
128 133
 
129
-        foreach ($tokens as $token) {
130
-            if (!isset($syntax[$token->grammar])) {
134
+        foreach ($tokens as $token)
135
+        {
136
+            if (!isset($syntax[$token->grammar]))
137
+            {
131 138
                 throw new SyntaxException('Undefined token', $token);
132 139
             }
133 140
 
134 141
             $syntax[$token->grammar]->handle($this, $asm, $token);
135 142
         }
136 143
 
137
-        if ($asm->getNode() !== $node) {
144
+        if ($asm->getNode() !== $node)
145
+        {
138 146
             throw new SyntaxException(
139 147
                 'Invalid node hierarchy, unclosed ' . $asm->getStackPath(),
140 148
                 $asm->getNode()->getContext()->getToken()
Please login to merge, or discard this patch.
src/Stempler/tests/Transform/BaseTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 {
35 35
     protected function compile(string $source, array $visitors = [], LoaderInterface $loader = null)
36 36
     {
37
-        if ($loader === null) {
37
+        if ($loader === null){
38 38
             $loader = new StringLoader();
39 39
             $loader->set('root', $source);
40 40
         }
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
         $builder->getCompiler()->addRenderer(new DynamicRenderer(new DirectiveGroup()));
70 70
         $builder->getCompiler()->addRenderer(new HTMLRenderer());
71 71
 
72
-        foreach ($this->getVisitors() as $visitor) {
72
+        foreach ($this->getVisitors() as $visitor){
73 73
             $builder->addVisitor($visitor);
74 74
         }
75 75
 
76
-        foreach ($visitors as $visitor) {
76
+        foreach ($visitors as $visitor){
77 77
             $builder->addVisitor($visitor);
78 78
         }
79 79
 
@@ -90,6 +90,6 @@  discard block
 block discarded – undo
90 90
      */
91 91
     protected function getFixtureLoader(): LoaderInterface
92 92
     {
93
-        return new DirectoryLoader(__DIR__ . '/../fixtures');
93
+        return new DirectoryLoader(__DIR__.'/../fixtures');
94 94
     }
95 95
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@  discard block
 block discarded – undo
34 34
 {
35 35
     protected function compile(string $source, array $visitors = [], LoaderInterface $loader = null)
36 36
     {
37
-        if ($loader === null) {
37
+        if ($loader === null)
38
+        {
38 39
             $loader = new StringLoader();
39 40
             $loader->set('root', $source);
40 41
         }
@@ -69,11 +70,13 @@  discard block
 block discarded – undo
69 70
         $builder->getCompiler()->addRenderer(new DynamicRenderer(new DirectiveGroup()));
70 71
         $builder->getCompiler()->addRenderer(new HTMLRenderer());
71 72
 
72
-        foreach ($this->getVisitors() as $visitor) {
73
+        foreach ($this->getVisitors() as $visitor)
74
+        {
73 75
             $builder->addVisitor($visitor);
74 76
         }
75 77
 
76
-        foreach ($visitors as $visitor) {
78
+        foreach ($visitors as $visitor)
79
+        {
77 80
             $builder->addVisitor($visitor);
78 81
         }
79 82
 
Please login to merge, or discard this patch.
src/Stempler/tests/Transform/DynamicToPHPTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     public function testVerbatim4(): void
105 105
     {
106 106
         $this->assertSame(
107
-            '<script>alert(<?php echo json_encode' .
107
+            '<script>alert(<?php echo json_encode'.
108 108
             '("hello\' \'world", JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT, 512); ?>)</script>',
109 109
             $res = $this->compile('<script>alert({{ "hello\' \'world" }})</script>')->getContent()
110 110
         );
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         ob_start();
129 129
 
130
-        eval('?>' . $body);
130
+        eval('?>'.$body);
131 131
 
132 132
         return ob_get_clean();
133 133
     }
Please login to merge, or discard this patch.
src/Stempler/tests/Transform/ImportedStackTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         );
148 148
 
149 149
         $loader->set(
150
-            'grid' . DIRECTORY_SEPARATOR . 'render',
150
+            'grid'.DIRECTORY_SEPARATOR.'render',
151 151
             '
152 152
 <table>
153 153
 <thead>
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         );
163 163
 
164 164
         $loader->set(
165
-            'grid' . DIRECTORY_SEPARATOR . 'cell',
165
+            'grid'.DIRECTORY_SEPARATOR.'cell',
166 166
             '
167 167
 <stack:push name="head"><tr>${title}</tr></stack:push>
168 168
 <stack:push name="body"><td>${context}</td></stack:push>
Please login to merge, or discard this patch.
src/Stempler/tests/Compiler/BaseTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     protected function compile(Template $document): string
35 35
     {
36 36
         $compiler = new Compiler();
37
-        foreach (static::RENDERS as $renderer) {
37
+        foreach (static::RENDERS as $renderer){
38 38
             $compiler->addRenderer(new $renderer());
39 39
         }
40 40
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $parser = new Parser();
51 51
 
52
-        foreach (static::GRAMMARS as $grammar => $syntax) {
52
+        foreach (static::GRAMMARS as $grammar => $syntax){
53 53
             $parser->addSyntax(new $grammar(), new $syntax());
54 54
         }
55 55
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@  discard block
 block discarded – undo
34 34
     protected function compile(Template $document): string
35 35
     {
36 36
         $compiler = new Compiler();
37
-        foreach (static::RENDERS as $renderer) {
37
+        foreach (static::RENDERS as $renderer)
38
+        {
38 39
             $compiler->addRenderer(new $renderer());
39 40
         }
40 41
 
@@ -49,7 +50,8 @@  discard block
 block discarded – undo
49 50
     {
50 51
         $parser = new Parser();
51 52
 
52
-        foreach (static::GRAMMARS as $grammar => $syntax) {
53
+        foreach (static::GRAMMARS as $grammar => $syntax)
54
+        {
53 55
             $parser->addSyntax(new $grammar(), new $syntax());
54 56
         }
55 57
 
Please login to merge, or discard this patch.