@@ -26,11 +26,11 @@ |
||
26 | 26 | |
27 | 27 | public function store(string $name): void |
28 | 28 | { |
29 | - $this->storage[$name] = file_get_contents($this->dir . $name); |
|
29 | + $this->storage[$name] = file_get_contents($this->dir.$name); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function restore(string $name): void |
33 | 33 | { |
34 | - file_put_contents($this->dir . $name, $this->storage[$name]); |
|
34 | + file_put_contents($this->dir.$name, $this->storage[$name]); |
|
35 | 35 | } |
36 | 36 | } |
@@ -57,12 +57,12 @@ |
||
57 | 57 | { |
58 | 58 | $line = 0; |
59 | 59 | |
60 | - for ($i = 0; $i < $offset; $i++) { |
|
61 | - if (!isset($content[$i])) { |
|
60 | + for ($i = 0; $i < $offset; $i++){ |
|
61 | + if (!isset($content[$i])){ |
|
62 | 62 | break; |
63 | 63 | } |
64 | 64 | |
65 | - if ($content[$i] === "\n") { |
|
65 | + if ($content[$i] === "\n"){ |
|
66 | 66 | $line++; |
67 | 67 | } |
68 | 68 | } |
@@ -57,12 +57,15 @@ |
||
57 | 57 | { |
58 | 58 | $line = 0; |
59 | 59 | |
60 | - for ($i = 0; $i < $offset; $i++) { |
|
61 | - if (!isset($content[$i])) { |
|
60 | + for ($i = 0; $i < $offset; $i++) |
|
61 | + { |
|
62 | + if (!isset($content[$i])) |
|
63 | + { |
|
62 | 64 | break; |
63 | 65 | } |
64 | 66 | |
65 | - if ($content[$i] === "\n") { |
|
67 | + if ($content[$i] === "\n") |
|
68 | + { |
|
66 | 69 | $line++; |
67 | 70 | } |
68 | 71 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | public function load(string $path): Source |
34 | 34 | { |
35 | - if (!array_key_exists($path, $this->paths)) { |
|
35 | + if (!array_key_exists($path, $this->paths)){ |
|
36 | 36 | throw new LoaderException("Unable to load path `{$path}`"); |
37 | 37 | } |
38 | 38 |
@@ -32,7 +32,8 @@ |
||
32 | 32 | */ |
33 | 33 | public function load(string $path): Source |
34 | 34 | { |
35 | - if (!array_key_exists($path, $this->paths)) { |
|
35 | + if (!array_key_exists($path, $this->paths)) |
|
36 | + { |
|
36 | 37 | throw new LoaderException("Unable to load path `{$path}`"); |
37 | 38 | } |
38 | 39 |
@@ -50,7 +50,7 @@ |
||
50 | 50 | $this->extension |
51 | 51 | ); |
52 | 52 | |
53 | - if (!file_exists($filename)) { |
|
53 | + if (!file_exists($filename)){ |
|
54 | 54 | throw new LoaderException("Unable to load `{$path}`, no such file"); |
55 | 55 | } |
56 | 56 |
@@ -50,7 +50,8 @@ |
||
50 | 50 | $this->extension |
51 | 51 | ); |
52 | 52 | |
53 | - if (!file_exists($filename)) { |
|
53 | + if (!file_exists($filename)) |
|
54 | + { |
|
54 | 55 | throw new LoaderException("Unable to load `{$path}`, no such file"); |
55 | 56 | } |
56 | 57 |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | { |
32 | 32 | $blocks = ['context' => []]; |
33 | 33 | |
34 | - foreach ($caller->attrs as $attr) { |
|
35 | - if (!$attr instanceof Attr || $attr->name instanceof NodeInterface) { |
|
34 | + foreach ($caller->attrs as $attr){ |
|
35 | + if (!$attr instanceof Attr || $attr->name instanceof NodeInterface){ |
|
36 | 36 | // ignore name when attribute is dynamic |
37 | 37 | $blocks[sprintf('attr-%s', count($blocks))] = $attr; |
38 | 38 | continue; |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | $blocks[$attr->name] = new QuotedValue($attr->value); |
43 | 43 | } |
44 | 44 | |
45 | - foreach ($caller->nodes as $node) { |
|
46 | - if ($node instanceof Block) { |
|
45 | + foreach ($caller->nodes as $node){ |
|
46 | + if ($node instanceof Block){ |
|
47 | 47 | $blocks[$node->name] = $node->nodes; |
48 | - } else { |
|
48 | + }else{ |
|
49 | 49 | $blocks['context'][] = $node; |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - if ($blocks['context'] === []) { |
|
53 | + if ($blocks['context'] === []){ |
|
54 | 54 | unset($blocks['context']); |
55 | 55 | } |
56 | 56 |
@@ -31,8 +31,10 @@ discard block |
||
31 | 31 | { |
32 | 32 | $blocks = ['context' => []]; |
33 | 33 | |
34 | - foreach ($caller->attrs as $attr) { |
|
35 | - if (!$attr instanceof Attr || $attr->name instanceof NodeInterface) { |
|
34 | + foreach ($caller->attrs as $attr) |
|
35 | + { |
|
36 | + if (!$attr instanceof Attr || $attr->name instanceof NodeInterface) |
|
37 | + { |
|
36 | 38 | // ignore name when attribute is dynamic |
37 | 39 | $blocks[sprintf('attr-%s', count($blocks))] = $attr; |
38 | 40 | continue; |
@@ -42,15 +44,20 @@ discard block |
||
42 | 44 | $blocks[$attr->name] = new QuotedValue($attr->value); |
43 | 45 | } |
44 | 46 | |
45 | - foreach ($caller->nodes as $node) { |
|
46 | - if ($node instanceof Block) { |
|
47 | + foreach ($caller->nodes as $node) |
|
48 | + { |
|
49 | + if ($node instanceof Block) |
|
50 | + { |
|
47 | 51 | $blocks[$node->name] = $node->nodes; |
48 | - } else { |
|
52 | + } |
|
53 | + else |
|
54 | + { |
|
49 | 55 | $blocks['context'][] = $node; |
50 | 56 | } |
51 | 57 | } |
52 | 58 | |
53 | - if ($blocks['context'] === []) { |
|
59 | + if ($blocks['context'] === []) |
|
60 | + { |
|
54 | 61 | unset($blocks['context']); |
55 | 62 | } |
56 | 63 |
@@ -96,7 +96,7 @@ |
||
96 | 96 | protected function traverse(array $nodes, VisitorInterface ...$visitors) |
97 | 97 | { |
98 | 98 | $traverser = new Traverser(); |
99 | - foreach ($visitors as $visitor) { |
|
99 | + foreach ($visitors as $visitor){ |
|
100 | 100 | $traverser->addVisitor($visitor); |
101 | 101 | } |
102 | 102 |
@@ -96,7 +96,8 @@ |
||
96 | 96 | protected function traverse(array $nodes, VisitorInterface ...$visitors) |
97 | 97 | { |
98 | 98 | $traverser = new Traverser(); |
99 | - foreach ($visitors as $visitor) { |
|
99 | + foreach ($visitors as $visitor) |
|
100 | + { |
|
100 | 101 | $traverser->addVisitor($visitor); |
101 | 102 | } |
102 | 103 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | public function enterNode($node, VisitorContext $ctx): void |
38 | 38 | { |
39 | - if ($node instanceof Block && $node->getContext()->getPath() === $this->path) { |
|
39 | + if ($node instanceof Block && $node->getContext()->getPath() === $this->path){ |
|
40 | 40 | $node->name = null; |
41 | 41 | } |
42 | 42 | } |
@@ -36,7 +36,8 @@ |
||
36 | 36 | */ |
37 | 37 | public function enterNode($node, VisitorContext $ctx): void |
38 | 38 | { |
39 | - if ($node instanceof Block && $node->getContext()->getPath() === $this->path) { |
|
39 | + if ($node instanceof Block && $node->getContext()->getPath() === $this->path) |
|
40 | + { |
|
40 | 41 | $node->name = null; |
41 | 42 | } |
42 | 43 | } |
@@ -44,9 +44,9 @@ |
||
44 | 44 | */ |
45 | 45 | public function leaveNode($node, VisitorContext $ctx) |
46 | 46 | { |
47 | - if ($node instanceof Raw && trim($node->content, $this->trim) === '') { |
|
48 | - foreach ($ctx->getScope() as $scope) { |
|
49 | - if ($scope instanceof Attr) { |
|
47 | + if ($node instanceof Raw && trim($node->content, $this->trim) === ''){ |
|
48 | + foreach ($ctx->getScope() as $scope){ |
|
49 | + if ($scope instanceof Attr){ |
|
50 | 50 | // do not trim attribute values |
51 | 51 | return null; |
52 | 52 | } |
@@ -44,9 +44,12 @@ |
||
44 | 44 | */ |
45 | 45 | public function leaveNode($node, VisitorContext $ctx) |
46 | 46 | { |
47 | - if ($node instanceof Raw && trim($node->content, $this->trim) === '') { |
|
48 | - foreach ($ctx->getScope() as $scope) { |
|
49 | - if ($scope instanceof Attr) { |
|
47 | + if ($node instanceof Raw && trim($node->content, $this->trim) === '') |
|
48 | + { |
|
49 | + foreach ($ctx->getScope() as $scope) |
|
50 | + { |
|
51 | + if ($scope instanceof Attr) |
|
52 | + { |
|
50 | 53 | // do not trim attribute values |
51 | 54 | return null; |
52 | 55 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $this->path = $path; |
40 | 40 | $this->alias = $alias ?? $path; |
41 | 41 | |
42 | - if ($alias === null && strrpos($this->alias, '/') !== false) { |
|
42 | + if ($alias === null && strrpos($this->alias, '/') !== false){ |
|
43 | 43 | $this->alias = substr($this->alias, strrpos($this->alias, '/') + 1); |
44 | 44 | } |
45 | 45 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function resolve(Builder $builder, string $name): ?Template |
69 | 69 | { |
70 | - if ($this->alias !== $name) { |
|
70 | + if ($this->alias !== $name){ |
|
71 | 71 | return null; |
72 | 72 | } |
73 | 73 |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | $this->path = $path; |
40 | 40 | $this->alias = $alias ?? $path; |
41 | 41 | |
42 | - if ($alias === null && strrpos($this->alias, '/') !== false) { |
|
42 | + if ($alias === null && strrpos($this->alias, '/') !== false) |
|
43 | + { |
|
43 | 44 | $this->alias = substr($this->alias, strrpos($this->alias, '/') + 1); |
44 | 45 | } |
45 | 46 | |
@@ -67,7 +68,8 @@ discard block |
||
67 | 68 | */ |
68 | 69 | public function resolve(Builder $builder, string $name): ?Template |
69 | 70 | { |
70 | - if ($this->alias !== $name) { |
|
71 | + if ($this->alias !== $name) |
|
72 | + { |
|
71 | 73 | return null; |
72 | 74 | } |
73 | 75 |