@@ -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 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | */ |
47 | 47 | public function resolve(Builder $builder, string $name): ?Template |
48 | 48 | { |
49 | - if ($name !== $this->name) { |
|
49 | + if ($name !== $this->name){ |
|
50 | 50 | return null; |
51 | 51 | } |
52 | 52 |
@@ -46,7 +46,8 @@ |
||
46 | 46 | */ |
47 | 47 | public function resolve(Builder $builder, string $name): ?Template |
48 | 48 | { |
49 | - if ($name !== $this->name) { |
|
49 | + if ($name !== $this->name) |
|
50 | + { |
|
50 | 51 | return null; |
51 | 52 | } |
52 | 53 |
@@ -49,6 +49,6 @@ |
||
49 | 49 | $path = substr($name, strlen($this->prefix) + 1); |
50 | 50 | $path = str_replace('.', DIRECTORY_SEPARATOR, $path); |
51 | 51 | |
52 | - return $builder->load($this->path . DIRECTORY_SEPARATOR . $path); |
|
52 | + return $builder->load($this->path.DIRECTORY_SEPARATOR.$path); |
|
53 | 53 | } |
54 | 54 | } |
@@ -50,19 +50,19 @@ |
||
50 | 50 | */ |
51 | 51 | public function resolve(Builder $builder, string $name): ?Template |
52 | 52 | { |
53 | - if ($this->template === null) { |
|
53 | + if ($this->template === null){ |
|
54 | 54 | $this->template = $builder->load($this->path); |
55 | 55 | } |
56 | 56 | |
57 | 57 | $path = $name; |
58 | - if ($this->prefix !== null) { |
|
58 | + if ($this->prefix !== null){ |
|
59 | 59 | $path = substr($path, strlen($this->prefix) + 1); |
60 | 60 | } |
61 | 61 | |
62 | 62 | /** @var ImportInterface $import */ |
63 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
63 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import){ |
|
64 | 64 | $tpl = $import->resolve($builder, $path); |
65 | - if ($tpl !== null) { |
|
65 | + if ($tpl !== null){ |
|
66 | 66 | return $tpl; |
67 | 67 | } |
68 | 68 | } |
@@ -50,19 +50,23 @@ |
||
50 | 50 | */ |
51 | 51 | public function resolve(Builder $builder, string $name): ?Template |
52 | 52 | { |
53 | - if ($this->template === null) { |
|
53 | + if ($this->template === null) |
|
54 | + { |
|
54 | 55 | $this->template = $builder->load($this->path); |
55 | 56 | } |
56 | 57 | |
57 | 58 | $path = $name; |
58 | - if ($this->prefix !== null) { |
|
59 | + if ($this->prefix !== null) |
|
60 | + { |
|
59 | 61 | $path = substr($path, strlen($this->prefix) + 1); |
60 | 62 | } |
61 | 63 | |
62 | 64 | /** @var ImportInterface $import */ |
63 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
65 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import) |
|
66 | + { |
|
64 | 67 | $tpl = $import->resolve($builder, $path); |
65 | - if ($tpl !== null) { |
|
68 | + if ($tpl !== null) |
|
69 | + { |
|
66 | 70 | return $tpl; |
67 | 71 | } |
68 | 72 | } |