@@ -34,7 +34,7 @@ discard block |
||
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 |
||
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 |
@@ -34,7 +34,8 @@ discard block |
||
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 |
||
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 |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | { |
44 | 44 | $builder = $this->getBuilder($this->getFixtureLoader()); |
45 | 45 | |
46 | - try { |
|
46 | + try{ |
|
47 | 47 | $builder->compile('broken')->getContent(); |
48 | - } catch (ParserException $e) { |
|
48 | + }catch (ParserException $e){ |
|
49 | 49 | $this->assertInstanceOf(SyntaxException::class, $e->getPrevious()); |
50 | 50 | $this->assertStringContainsString('broken.dark.php', $e->getFile()); |
51 | 51 | $this->assertSame(3, $e->getLine()); |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | { |
57 | 57 | $builder = $this->getBuilder($this->getFixtureLoader()); |
58 | 58 | |
59 | - try { |
|
59 | + try{ |
|
60 | 60 | $builder->compile('import/bad-element'); |
61 | - } catch (ImportException $e) { |
|
61 | + }catch (ImportException $e){ |
|
62 | 62 | $this->assertStringContainsString('bad-element.dark.php', $e->getFile()); |
63 | 63 | $this->assertSame(1, $e->getLine()); |
64 | 64 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | { |
69 | 69 | $builder = $this->getBuilder($this->getFixtureLoader()); |
70 | 70 | |
71 | - try { |
|
71 | + try{ |
|
72 | 72 | $builder->compile('import/bad-element-3'); |
73 | - } catch (ImportException $e) { |
|
73 | + }catch (ImportException $e){ |
|
74 | 74 | $this->assertStringContainsString('bad-element-3.dark.php', $e->getFile()); |
75 | 75 | $this->assertSame(3, $e->getLine()); |
76 | 76 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | { |
81 | 81 | $builder = $this->getBuilder($this->getFixtureLoader()); |
82 | 82 | |
83 | - try { |
|
83 | + try{ |
|
84 | 84 | $builder->compile('import/bad-dir'); |
85 | - } catch (ImportException $e) { |
|
85 | + }catch (ImportException $e){ |
|
86 | 86 | $this->assertStringContainsString('bad-dir.dark.php', $e->getFile()); |
87 | 87 | $this->assertSame(1, $e->getLine()); |
88 | 88 | } |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | { |
93 | 93 | $builder = $this->getBuilder($this->getFixtureLoader()); |
94 | 94 | |
95 | - try { |
|
95 | + try{ |
|
96 | 96 | $builder->compile('import/bad-dir-2'); |
97 | - } catch (ImportException $e) { |
|
97 | + }catch (ImportException $e){ |
|
98 | 98 | $this->assertStringContainsString('bad-dir-2.dark.php', $e->getFile()); |
99 | 99 | $this->assertSame(2, $e->getLine()); |
100 | 100 | } |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | { |
105 | 105 | $builder = $this->getBuilder($this->getFixtureLoader()); |
106 | 106 | |
107 | - try { |
|
107 | + try{ |
|
108 | 108 | $builder->compile('bad-directive'); |
109 | - } catch (DirectiveException $e) { |
|
109 | + }catch (DirectiveException $e){ |
|
110 | 110 | $this->assertStringContainsString('bad-directive.dark.php', $e->getFile()); |
111 | 111 | $this->assertSame(2, $e->getLine()); |
112 | 112 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | { |
117 | 117 | $builder = $this->getBuilder($this->getFixtureLoader()); |
118 | 118 | |
119 | - try { |
|
119 | + try{ |
|
120 | 120 | $builder->compile('exception-in-import'); |
121 | - } catch (ImportException $e) { |
|
121 | + }catch (ImportException $e){ |
|
122 | 122 | $this->assertStringContainsString('exception-in-import.dark.php', $e->getFile()); |
123 | 123 | $this->assertSame(3, $e->getLine()); |
124 | 124 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | { |
134 | 134 | $builder = $this->getBuilder($this->getFixtureLoader()); |
135 | 135 | |
136 | - try { |
|
136 | + try{ |
|
137 | 137 | $builder->compile('exception-in-import-2'); |
138 | - } catch (ImportException $e) { |
|
138 | + }catch (ImportException $e){ |
|
139 | 139 | $this->assertInstanceOf(ImportException::class, $e); |
140 | 140 | $this->assertStringContainsString('exception-in-import-2.dark.php', $e->getFile()); |
141 | 141 | $this->assertSame(3, $e->getLine()); |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | { |
152 | 152 | $builder = $this->getBuilder($this->getFixtureLoader()); |
153 | 153 | |
154 | - try { |
|
154 | + try{ |
|
155 | 155 | $builder->compile('bad-extends'); |
156 | - } catch (ExtendsException $e) { |
|
156 | + }catch (ExtendsException $e){ |
|
157 | 157 | $this->assertStringContainsString('bad-extends.dark.php', $e->getFile()); |
158 | 158 | $this->assertSame(1, $e->getLine()); |
159 | 159 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | { |
166 | 166 | $builder = $this->getBuilder($this->getFixtureLoader()); |
167 | 167 | |
168 | - try { |
|
168 | + try{ |
|
169 | 169 | $builder->compile('bad-extends-2'); |
170 | - } catch (ExtendsException $e) { |
|
170 | + }catch (ExtendsException $e){ |
|
171 | 171 | $this->assertInstanceOf(ExtendsException::class, $e); |
172 | 172 | $this->assertStringContainsString('bad-extends-2.dark.php', $e->getFile()); |
173 | 173 | $this->assertSame(1, $e->getLine()); |
@@ -43,9 +43,12 @@ discard block |
||
43 | 43 | { |
44 | 44 | $builder = $this->getBuilder($this->getFixtureLoader()); |
45 | 45 | |
46 | - try { |
|
46 | + try |
|
47 | + { |
|
47 | 48 | $builder->compile('broken')->getContent(); |
48 | - } catch (ParserException $e) { |
|
49 | + } |
|
50 | + catch (ParserException $e) |
|
51 | + { |
|
49 | 52 | $this->assertInstanceOf(SyntaxException::class, $e->getPrevious()); |
50 | 53 | $this->assertStringContainsString('broken.dark.php', $e->getFile()); |
51 | 54 | $this->assertSame(3, $e->getLine()); |
@@ -56,9 +59,12 @@ discard block |
||
56 | 59 | { |
57 | 60 | $builder = $this->getBuilder($this->getFixtureLoader()); |
58 | 61 | |
59 | - try { |
|
62 | + try |
|
63 | + { |
|
60 | 64 | $builder->compile('import/bad-element'); |
61 | - } catch (ImportException $e) { |
|
65 | + } |
|
66 | + catch (ImportException $e) |
|
67 | + { |
|
62 | 68 | $this->assertStringContainsString('bad-element.dark.php', $e->getFile()); |
63 | 69 | $this->assertSame(1, $e->getLine()); |
64 | 70 | } |
@@ -68,9 +74,12 @@ discard block |
||
68 | 74 | { |
69 | 75 | $builder = $this->getBuilder($this->getFixtureLoader()); |
70 | 76 | |
71 | - try { |
|
77 | + try |
|
78 | + { |
|
72 | 79 | $builder->compile('import/bad-element-3'); |
73 | - } catch (ImportException $e) { |
|
80 | + } |
|
81 | + catch (ImportException $e) |
|
82 | + { |
|
74 | 83 | $this->assertStringContainsString('bad-element-3.dark.php', $e->getFile()); |
75 | 84 | $this->assertSame(3, $e->getLine()); |
76 | 85 | } |
@@ -80,9 +89,12 @@ discard block |
||
80 | 89 | { |
81 | 90 | $builder = $this->getBuilder($this->getFixtureLoader()); |
82 | 91 | |
83 | - try { |
|
92 | + try |
|
93 | + { |
|
84 | 94 | $builder->compile('import/bad-dir'); |
85 | - } catch (ImportException $e) { |
|
95 | + } |
|
96 | + catch (ImportException $e) |
|
97 | + { |
|
86 | 98 | $this->assertStringContainsString('bad-dir.dark.php', $e->getFile()); |
87 | 99 | $this->assertSame(1, $e->getLine()); |
88 | 100 | } |
@@ -92,9 +104,12 @@ discard block |
||
92 | 104 | { |
93 | 105 | $builder = $this->getBuilder($this->getFixtureLoader()); |
94 | 106 | |
95 | - try { |
|
107 | + try |
|
108 | + { |
|
96 | 109 | $builder->compile('import/bad-dir-2'); |
97 | - } catch (ImportException $e) { |
|
110 | + } |
|
111 | + catch (ImportException $e) |
|
112 | + { |
|
98 | 113 | $this->assertStringContainsString('bad-dir-2.dark.php', $e->getFile()); |
99 | 114 | $this->assertSame(2, $e->getLine()); |
100 | 115 | } |
@@ -104,9 +119,12 @@ discard block |
||
104 | 119 | { |
105 | 120 | $builder = $this->getBuilder($this->getFixtureLoader()); |
106 | 121 | |
107 | - try { |
|
122 | + try |
|
123 | + { |
|
108 | 124 | $builder->compile('bad-directive'); |
109 | - } catch (DirectiveException $e) { |
|
125 | + } |
|
126 | + catch (DirectiveException $e) |
|
127 | + { |
|
110 | 128 | $this->assertStringContainsString('bad-directive.dark.php', $e->getFile()); |
111 | 129 | $this->assertSame(2, $e->getLine()); |
112 | 130 | } |
@@ -116,9 +134,12 @@ discard block |
||
116 | 134 | { |
117 | 135 | $builder = $this->getBuilder($this->getFixtureLoader()); |
118 | 136 | |
119 | - try { |
|
137 | + try |
|
138 | + { |
|
120 | 139 | $builder->compile('exception-in-import'); |
121 | - } catch (ImportException $e) { |
|
140 | + } |
|
141 | + catch (ImportException $e) |
|
142 | + { |
|
122 | 143 | $this->assertStringContainsString('exception-in-import.dark.php', $e->getFile()); |
123 | 144 | $this->assertSame(3, $e->getLine()); |
124 | 145 | |
@@ -133,9 +154,12 @@ discard block |
||
133 | 154 | { |
134 | 155 | $builder = $this->getBuilder($this->getFixtureLoader()); |
135 | 156 | |
136 | - try { |
|
157 | + try |
|
158 | + { |
|
137 | 159 | $builder->compile('exception-in-import-2'); |
138 | - } catch (ImportException $e) { |
|
160 | + } |
|
161 | + catch (ImportException $e) |
|
162 | + { |
|
139 | 163 | $this->assertInstanceOf(ImportException::class, $e); |
140 | 164 | $this->assertStringContainsString('exception-in-import-2.dark.php', $e->getFile()); |
141 | 165 | $this->assertSame(3, $e->getLine()); |
@@ -151,9 +175,12 @@ discard block |
||
151 | 175 | { |
152 | 176 | $builder = $this->getBuilder($this->getFixtureLoader()); |
153 | 177 | |
154 | - try { |
|
178 | + try |
|
179 | + { |
|
155 | 180 | $builder->compile('bad-extends'); |
156 | - } catch (ExtendsException $e) { |
|
181 | + } |
|
182 | + catch (ExtendsException $e) |
|
183 | + { |
|
157 | 184 | $this->assertStringContainsString('bad-extends.dark.php', $e->getFile()); |
158 | 185 | $this->assertSame(1, $e->getLine()); |
159 | 186 | |
@@ -165,9 +192,12 @@ discard block |
||
165 | 192 | { |
166 | 193 | $builder = $this->getBuilder($this->getFixtureLoader()); |
167 | 194 | |
168 | - try { |
|
195 | + try |
|
196 | + { |
|
169 | 197 | $builder->compile('bad-extends-2'); |
170 | - } catch (ExtendsException $e) { |
|
198 | + } |
|
199 | + catch (ExtendsException $e) |
|
200 | + { |
|
171 | 201 | $this->assertInstanceOf(ExtendsException::class, $e); |
172 | 202 | $this->assertStringContainsString('bad-extends-2.dark.php', $e->getFile()); |
173 | 203 | $this->assertSame(1, $e->getLine()); |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | $doc = $this->parse('<a href="url"></a>'); |
40 | 40 | |
41 | 41 | $t = new Traverser(); |
42 | - $t->addVisitor(new class() implements VisitorInterface { |
|
42 | + $t->addVisitor(new class() implements VisitorInterface{ |
|
43 | 43 | public function enterNode($node, VisitorContext $ctx): void |
44 | 44 | { |
45 | - if ($node instanceof Tag && $node->name == 'a') { |
|
45 | + if ($node instanceof Tag && $node->name == 'a'){ |
|
46 | 46 | $node->name = 'b'; |
47 | 47 | } |
48 | 48 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | $doc = $this->parse('<a href="url"></a>'); |
66 | 66 | |
67 | 67 | $t = new Traverser(); |
68 | - $t->addVisitor(new class() implements VisitorInterface { |
|
68 | + $t->addVisitor(new class() implements VisitorInterface{ |
|
69 | 69 | public function enterNode($node, VisitorContext $ctx): void |
70 | 70 | { |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function leaveNode($node, VisitorContext $ctx) |
74 | 74 | { |
75 | - if ($node instanceof Tag && $node->name == 'a') { |
|
75 | + if ($node instanceof Tag && $node->name == 'a'){ |
|
76 | 76 | $new = new Tag(); |
77 | 77 | $new->name = 'link'; |
78 | 78 | $new->void = true; |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | $doc = $this->parse('<a href="url"><b></b>hello</a>'); |
98 | 98 | |
99 | 99 | $t = new Traverser(); |
100 | - $t->addVisitor(new class() implements VisitorInterface { |
|
100 | + $t->addVisitor(new class() implements VisitorInterface{ |
|
101 | 101 | public function enterNode($node, VisitorContext $ctx): void |
102 | 102 | { |
103 | 103 | } |
104 | 104 | |
105 | 105 | public function leaveNode($node, VisitorContext $ctx) |
106 | 106 | { |
107 | - if ($node instanceof Tag && $node->name == 'b') { |
|
107 | + if ($node instanceof Tag && $node->name == 'b'){ |
|
108 | 108 | return VisitorInterface::REMOVE_NODE; |
109 | 109 | } |
110 | 110 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | public function enterNode($node, VisitorContext $ctx): void |
132 | 132 | { |
133 | - if ($ctx->getCurrentNode() instanceof Raw) { |
|
133 | + if ($ctx->getCurrentNode() instanceof Raw){ |
|
134 | 134 | $this->assertInstanceOf(Tag::class, $ctx->getParentNode()); |
135 | 135 | $this->assertSame('b', $ctx->getParentNode()->name); |
136 | 136 |
@@ -39,10 +39,12 @@ discard block |
||
39 | 39 | $doc = $this->parse('<a href="url"></a>'); |
40 | 40 | |
41 | 41 | $t = new Traverser(); |
42 | - $t->addVisitor(new class() implements VisitorInterface { |
|
42 | + $t->addVisitor(new class() implements VisitorInterface |
|
43 | + { |
|
43 | 44 | public function enterNode($node, VisitorContext $ctx): void |
44 | 45 | { |
45 | - if ($node instanceof Tag && $node->name == 'a') { |
|
46 | + if ($node instanceof Tag && $node->name == 'a') |
|
47 | + { |
|
46 | 48 | $node->name = 'b'; |
47 | 49 | } |
48 | 50 | } |
@@ -65,14 +67,16 @@ discard block |
||
65 | 67 | $doc = $this->parse('<a href="url"></a>'); |
66 | 68 | |
67 | 69 | $t = new Traverser(); |
68 | - $t->addVisitor(new class() implements VisitorInterface { |
|
70 | + $t->addVisitor(new class() implements VisitorInterface |
|
71 | + { |
|
69 | 72 | public function enterNode($node, VisitorContext $ctx): void |
70 | 73 | { |
71 | 74 | } |
72 | 75 | |
73 | 76 | public function leaveNode($node, VisitorContext $ctx) |
74 | 77 | { |
75 | - if ($node instanceof Tag && $node->name == 'a') { |
|
78 | + if ($node instanceof Tag && $node->name == 'a') |
|
79 | + { |
|
76 | 80 | $new = new Tag(); |
77 | 81 | $new->name = 'link'; |
78 | 82 | $new->void = true; |
@@ -97,14 +101,16 @@ discard block |
||
97 | 101 | $doc = $this->parse('<a href="url"><b></b>hello</a>'); |
98 | 102 | |
99 | 103 | $t = new Traverser(); |
100 | - $t->addVisitor(new class() implements VisitorInterface { |
|
104 | + $t->addVisitor(new class() implements VisitorInterface |
|
105 | + { |
|
101 | 106 | public function enterNode($node, VisitorContext $ctx): void |
102 | 107 | { |
103 | 108 | } |
104 | 109 | |
105 | 110 | public function leaveNode($node, VisitorContext $ctx) |
106 | 111 | { |
107 | - if ($node instanceof Tag && $node->name == 'b') { |
|
112 | + if ($node instanceof Tag && $node->name == 'b') |
|
113 | + { |
|
108 | 114 | return VisitorInterface::REMOVE_NODE; |
109 | 115 | } |
110 | 116 | } |
@@ -130,7 +136,8 @@ discard block |
||
130 | 136 | |
131 | 137 | public function enterNode($node, VisitorContext $ctx): void |
132 | 138 | { |
133 | - if ($ctx->getCurrentNode() instanceof Raw) { |
|
139 | + if ($ctx->getCurrentNode() instanceof Raw) |
|
140 | + { |
|
134 | 141 | $this->assertInstanceOf(Tag::class, $ctx->getParentNode()); |
135 | 142 | $this->assertSame('b', $ctx->getParentNode()->name); |
136 | 143 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public function testIterate(): void |
32 | 32 | { |
33 | 33 | $out = ''; |
34 | - foreach ($this->buffer('abc') as $n) { |
|
34 | + foreach ($this->buffer('abc') as $n){ |
|
35 | 35 | $out .= $n->char; |
36 | 36 | } |
37 | 37 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | private function generate(StreamInterface $src) |
153 | 153 | { |
154 | - while (!$src->isEOI()) { |
|
154 | + while (!$src->isEOI()){ |
|
155 | 155 | yield new Byte($src->getOffset(), $src->peak()); |
156 | 156 | } |
157 | 157 | } |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | public function testIterate(): void |
32 | 32 | { |
33 | 33 | $out = ''; |
34 | - foreach ($this->buffer('abc') as $n) { |
|
34 | + foreach ($this->buffer('abc') as $n) |
|
35 | + { |
|
35 | 36 | $out .= $n->char; |
36 | 37 | } |
37 | 38 | |
@@ -151,7 +152,8 @@ discard block |
||
151 | 152 | |
152 | 153 | private function generate(StreamInterface $src) |
153 | 154 | { |
154 | - while (!$src->isEOI()) { |
|
155 | + while (!$src->isEOI()) |
|
156 | + { |
|
155 | 157 | yield new Byte($src->getOffset(), $src->peak()); |
156 | 158 | } |
157 | 159 | } |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | { |
28 | 28 | $parsed = $this->tokens($source); |
29 | 29 | |
30 | - if (count($tokens) !== count($parsed)) { |
|
30 | + if (count($tokens) !== count($parsed)){ |
|
31 | 31 | $this->fail('Token count mismatch'); |
32 | 32 | } |
33 | 33 | |
34 | - foreach ($tokens as $index => $token) { |
|
34 | + foreach ($tokens as $index => $token){ |
|
35 | 35 | $this->assertSame($token->type, $parsed[$index]->type, 'Token type mismatch'); |
36 | 36 | $this->assertSame($token->offset, $parsed[$index]->offset, 'Token offset mismatch'); |
37 | 37 | $this->assertSame($token->content, $parsed[$index]->content, 'Token content mismatch'); |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | protected function tokens(string $source): array |
42 | 42 | { |
43 | 43 | $lexer = new Lexer(); |
44 | - foreach (static::GRAMMARS as $grammar) { |
|
44 | + foreach (static::GRAMMARS as $grammar){ |
|
45 | 45 | $lexer->addGrammar(new $grammar()); |
46 | 46 | } |
47 | 47 | |
48 | 48 | $tokens = []; |
49 | - foreach ($lexer->parse(new StringStream($source)) as $t) { |
|
49 | + foreach ($lexer->parse(new StringStream($source)) as $t){ |
|
50 | 50 | $tokens[] = $t; |
51 | 51 | } |
52 | 52 |
@@ -27,11 +27,13 @@ discard block |
||
27 | 27 | { |
28 | 28 | $parsed = $this->tokens($source); |
29 | 29 | |
30 | - if (count($tokens) !== count($parsed)) { |
|
30 | + if (count($tokens) !== count($parsed)) |
|
31 | + { |
|
31 | 32 | $this->fail('Token count mismatch'); |
32 | 33 | } |
33 | 34 | |
34 | - foreach ($tokens as $index => $token) { |
|
35 | + foreach ($tokens as $index => $token) |
|
36 | + { |
|
35 | 37 | $this->assertSame($token->type, $parsed[$index]->type, 'Token type mismatch'); |
36 | 38 | $this->assertSame($token->offset, $parsed[$index]->offset, 'Token offset mismatch'); |
37 | 39 | $this->assertSame($token->content, $parsed[$index]->content, 'Token content mismatch'); |
@@ -41,12 +43,14 @@ discard block |
||
41 | 43 | protected function tokens(string $source): array |
42 | 44 | { |
43 | 45 | $lexer = new Lexer(); |
44 | - foreach (static::GRAMMARS as $grammar) { |
|
46 | + foreach (static::GRAMMARS as $grammar) |
|
47 | + { |
|
45 | 48 | $lexer->addGrammar(new $grammar()); |
46 | 49 | } |
47 | 50 | |
48 | 51 | $tokens = []; |
49 | - foreach ($lexer->parse(new StringStream($source)) as $t) { |
|
52 | + foreach ($lexer->parse(new StringStream($source)) as $t) |
|
53 | + { |
|
50 | 54 | $tokens[] = $t; |
51 | 55 | } |
52 | 56 |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | { |
34 | 34 | $parsed = $this->tokens($source); |
35 | 35 | |
36 | - if (count($tokens) !== count($parsed)) { |
|
36 | + if (count($tokens) !== count($parsed)){ |
|
37 | 37 | $this->fail('Token count mismatch'); |
38 | 38 | } |
39 | 39 | |
40 | - foreach ($tokens as $index => $token) { |
|
40 | + foreach ($tokens as $index => $token){ |
|
41 | 41 | $this->assertSame($token->type, $parsed[$index]->type, 'Token type mismatch'); |
42 | 42 | $this->assertSame($token->offset, $parsed[$index]->offset, 'Token offset mismatch'); |
43 | 43 | $this->assertSame($token->content, $parsed[$index]->content, 'Token content mismatch'); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $lexer = new Lexer(); |
50 | 50 | |
51 | 51 | $tokens = []; |
52 | - foreach ($lexer->parse(new StringStream($source)) as $t) { |
|
52 | + foreach ($lexer->parse(new StringStream($source)) as $t){ |
|
53 | 53 | $tokens[] = $t; |
54 | 54 | } |
55 | 55 |
@@ -33,11 +33,13 @@ discard block |
||
33 | 33 | { |
34 | 34 | $parsed = $this->tokens($source); |
35 | 35 | |
36 | - if (count($tokens) !== count($parsed)) { |
|
36 | + if (count($tokens) !== count($parsed)) |
|
37 | + { |
|
37 | 38 | $this->fail('Token count mismatch'); |
38 | 39 | } |
39 | 40 | |
40 | - foreach ($tokens as $index => $token) { |
|
41 | + foreach ($tokens as $index => $token) |
|
42 | + { |
|
41 | 43 | $this->assertSame($token->type, $parsed[$index]->type, 'Token type mismatch'); |
42 | 44 | $this->assertSame($token->offset, $parsed[$index]->offset, 'Token offset mismatch'); |
43 | 45 | $this->assertSame($token->content, $parsed[$index]->content, 'Token content mismatch'); |
@@ -49,7 +51,8 @@ discard block |
||
49 | 51 | $lexer = new Lexer(); |
50 | 52 | |
51 | 53 | $tokens = []; |
52 | - foreach ($lexer->parse(new StringStream($source)) as $t) { |
|
54 | + foreach ($lexer->parse(new StringStream($source)) as $t) |
|
55 | + { |
|
53 | 56 | $tokens[] = $t; |
54 | 57 | } |
55 | 58 |
@@ -36,9 +36,9 @@ |
||
36 | 36 | protected const DIRECTIVES = []; |
37 | 37 | |
38 | 38 | /** |
39 | - * @param Template $document |
|
40 | - * @return string |
|
41 | - */ |
|
39 | + * @param Template $document |
|
40 | + * @return string |
|
41 | + */ |
|
42 | 42 | protected function compile(Template $document): string |
43 | 43 | { |
44 | 44 | $compiler = new Compiler(); |
@@ -42,12 +42,12 @@ |
||
42 | 42 | protected function compile(Template $document): string |
43 | 43 | { |
44 | 44 | $compiler = new Compiler(); |
45 | - foreach (static::RENDERS as $renderer) { |
|
45 | + foreach (static::RENDERS as $renderer){ |
|
46 | 46 | $compiler->addRenderer(new $renderer()); |
47 | 47 | } |
48 | 48 | |
49 | 49 | $directiveGroup = new DirectiveGroup(); |
50 | - foreach (static::DIRECTIVES as $directive) { |
|
50 | + foreach (static::DIRECTIVES as $directive){ |
|
51 | 51 | $directiveGroup->addDirective(new $directive()); |
52 | 52 | } |
53 | 53 |
@@ -42,12 +42,14 @@ |
||
42 | 42 | protected function compile(Template $document): string |
43 | 43 | { |
44 | 44 | $compiler = new Compiler(); |
45 | - foreach (static::RENDERS as $renderer) { |
|
45 | + foreach (static::RENDERS as $renderer) |
|
46 | + { |
|
46 | 47 | $compiler->addRenderer(new $renderer()); |
47 | 48 | } |
48 | 49 | |
49 | 50 | $directiveGroup = new DirectiveGroup(); |
50 | - foreach (static::DIRECTIVES as $directive) { |
|
51 | + foreach (static::DIRECTIVES as $directive) |
|
52 | + { |
|
51 | 53 | $directiveGroup->addDirective(new $directive()); |
52 | 54 | } |
53 | 55 |
@@ -30,7 +30,7 @@ |
||
30 | 30 | { |
31 | 31 | $parser = new Parser(); |
32 | 32 | |
33 | - foreach (static::GRAMMARS as $grammar => $syntax) { |
|
33 | + foreach (static::GRAMMARS as $grammar => $syntax){ |
|
34 | 34 | $parser->addSyntax(new $grammar(), new $syntax()); |
35 | 35 | } |
36 | 36 |
@@ -30,7 +30,8 @@ |
||
30 | 30 | { |
31 | 31 | $parser = new Parser(); |
32 | 32 | |
33 | - foreach (static::GRAMMARS as $grammar => $syntax) { |
|
33 | + foreach (static::GRAMMARS as $grammar => $syntax) |
|
34 | + { |
|
34 | 35 | $parser->addSyntax(new $grammar(), new $syntax()); |
35 | 36 | } |
36 | 37 |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | AnnotationRegistry::registerLoader('class_exists'); |
68 | 68 | |
69 | 69 | $schema = $this->memory->loadData(self::MEMORY_SECTION); |
70 | - if (empty($schema) || !$cached) { |
|
70 | + if (empty($schema) || !$cached){ |
|
71 | 71 | $schema = $locator->findDeclarations(); |
72 | 72 | $this->memory->saveData(self::MEMORY_SECTION, $schema); |
73 | 73 | } |
74 | 74 | |
75 | 75 | $this->configureRoutes($schema); |
76 | 76 | |
77 | - foreach ($this->groups as $group) { |
|
77 | + foreach ($this->groups as $group){ |
|
78 | 78 | $group->flushRoutes(); |
79 | 79 | } |
80 | 80 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | private function configureRoutes(array $routes): void |
94 | 94 | { |
95 | - foreach ($routes as $name => $schema) { |
|
95 | + foreach ($routes as $name => $schema){ |
|
96 | 96 | $this->groups |
97 | 97 | ->getGroup($schema['group']) |
98 | 98 | ->registerRoute( |
@@ -67,14 +67,16 @@ discard block |
||
67 | 67 | AnnotationRegistry::registerLoader('class_exists'); |
68 | 68 | |
69 | 69 | $schema = $this->memory->loadData(self::MEMORY_SECTION); |
70 | - if (empty($schema) || !$cached) { |
|
70 | + if (empty($schema) || !$cached) |
|
71 | + { |
|
71 | 72 | $schema = $locator->findDeclarations(); |
72 | 73 | $this->memory->saveData(self::MEMORY_SECTION, $schema); |
73 | 74 | } |
74 | 75 | |
75 | 76 | $this->configureRoutes($schema); |
76 | 77 | |
77 | - foreach ($this->groups as $group) { |
|
78 | + foreach ($this->groups as $group) |
|
79 | + { |
|
78 | 80 | $group->flushRoutes(); |
79 | 81 | } |
80 | 82 | } |
@@ -92,7 +94,8 @@ discard block |
||
92 | 94 | */ |
93 | 95 | private function configureRoutes(array $routes): void |
94 | 96 | { |
95 | - foreach ($routes as $name => $schema) { |
|
97 | + foreach ($routes as $name => $schema) |
|
98 | + { |
|
96 | 99 | $this->groups |
97 | 100 | ->getGroup($schema['group']) |
98 | 101 | ->registerRoute( |