Passed
Push — master ( 72c793...7f699f )
by Kirill
03:22
created
src/Views/tests/LoaderTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $this->expectException(LoaderException::class);
25 25
 
26 26
         $loader = new ViewLoader([
27
-            'default' => __DIR__ . '/fixtures/default',
27
+            'default' => __DIR__.'/fixtures/default',
28 28
         ]);
29 29
 
30 30
         $loader->exists('view');
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $this->expectException(LoaderException::class);
36 36
 
37 37
         $loader = new ViewLoader([
38
-            'default' => __DIR__ . '/fixtures/default',
38
+            'default' => __DIR__.'/fixtures/default',
39 39
         ]);
40 40
 
41 41
         $loader->list();
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $this->expectException(LoaderException::class);
47 47
 
48 48
         $loader = new ViewLoader([
49
-            'default' => __DIR__ . '/fixtures/default',
49
+            'default' => __DIR__.'/fixtures/default',
50 50
         ]);
51 51
 
52 52
         $loader->load('view');
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function testExists(): void
56 56
     {
57 57
         $loader = new ViewLoader([
58
-            'default' => __DIR__ . '/fixtures/default',
58
+            'default' => __DIR__.'/fixtures/default',
59 59
         ]);
60 60
 
61 61
         $loader = $loader->withExtension('php');
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     public function testList(): void
87 87
     {
88 88
         $loader = new ViewLoader([
89
-            'default' => __DIR__ . '/fixtures/default',
89
+            'default' => __DIR__.'/fixtures/default',
90 90
         ]);
91 91
 
92 92
         $loader = $loader->withExtension('php');
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         $this->expectException(LoaderException::class);
104 104
 
105 105
         $loader = new ViewLoader([
106
-            'default' => __DIR__ . '/fixtures/default',
106
+            'default' => __DIR__.'/fixtures/default',
107 107
         ]);
108 108
 
109 109
         $loader = $loader->withExtension('php');
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     public function testLoad(): void
147 147
     {
148 148
         $loader = new ViewLoader([
149
-            'default' => __DIR__ . '/fixtures/default',
149
+            'default' => __DIR__.'/fixtures/default',
150 150
         ]);
151 151
 
152 152
         $loader = $loader->withExtension('php');
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
     public function testMultipleNamespaces(): void
170 170
     {
171 171
         $loader = new ViewLoader([
172
-            'default' => __DIR__ . '/fixtures/default',
173
-            'other'   => __DIR__ . '/fixtures/other',
172
+            'default' => __DIR__.'/fixtures/default',
173
+            'other'   => __DIR__.'/fixtures/other',
174 174
 
175 175
         ]);
176 176
 
Please login to merge, or discard this patch.
src/Views/tests/ManagerTest.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $manager->addEngine(new NativeEngine($this->container, 'dark.php'));
37 37
 
38 38
         $ext = [];
39
-        foreach ($manager->getEngines() as $e) {
39
+        foreach ($manager->getEngines() as $e){
40 40
             $ext[] = $e->getLoader()->getExtension();
41 41
         }
42 42
 
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
                         'directory' => '/tmp',
125 125
                     ],
126 126
                     'namespaces'   => [
127
-                        'default' => __DIR__ . '/fixtures/default',
128
-                        'other'   => __DIR__ . '/fixtures/other',
127
+                        'default' => __DIR__.'/fixtures/default',
128
+                        'other'   => __DIR__.'/fixtures/other',
129 129
                     ],
130 130
                     'dependencies' => [
131 131
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@
 block discarded – undo
36 36
         $manager->addEngine(new NativeEngine($this->container, 'dark.php'));
37 37
 
38 38
         $ext = [];
39
-        foreach ($manager->getEngines() as $e) {
39
+        foreach ($manager->getEngines() as $e)
40
+        {
40 41
             $ext[] = $e->getLoader()->getExtension();
41 42
         }
42 43
 
Please login to merge, or discard this patch.
src/Views/tests/NativeTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
     public function testGet(): void
25 25
     {
26 26
         $loader = new ViewLoader([
27
-            'default' => __DIR__ . '/fixtures/default',
28
-            'other'   => __DIR__ . '/fixtures/other',
27
+            'default' => __DIR__.'/fixtures/default',
28
+            'other'   => __DIR__.'/fixtures/other',
29 29
         ]);
30 30
 
31 31
         $loader = $loader->withExtension('php');
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     public function testRenderWithValue(): void
52 52
     {
53 53
         $loader = new ViewLoader([
54
-            'default' => __DIR__ . '/fixtures/default',
55
-            'other'   => __DIR__ . '/fixtures/other',
54
+            'default' => __DIR__.'/fixtures/default',
55
+            'other'   => __DIR__.'/fixtures/other',
56 56
 
57 57
         ]);
58 58
 
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
         $this->expectException(RenderException::class);
71 71
 
72 72
         $loader = new ViewLoader([
73
-            'default' => __DIR__ . '/fixtures/default',
74
-            'other'   => __DIR__ . '/fixtures/other',
73
+            'default' => __DIR__.'/fixtures/default',
74
+            'other'   => __DIR__.'/fixtures/other',
75 75
 
76 76
         ]);
77 77
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
     public function testRenderBufferWithValue(): void
89 89
     {
90 90
         $loader = new ViewLoader([
91
-            'default' => __DIR__ . '/fixtures/default',
92
-            'other'   => __DIR__ . '/fixtures/other',
91
+            'default' => __DIR__.'/fixtures/default',
92
+            'other'   => __DIR__.'/fixtures/other',
93 93
 
94 94
         ]);
95 95
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
         $this->expectException(RenderException::class);
108 108
 
109 109
         $loader = new ViewLoader([
110
-            'default' => __DIR__ . '/fixtures/default',
111
-            'other'   => __DIR__ . '/fixtures/other',
110
+            'default' => __DIR__.'/fixtures/default',
111
+            'other'   => __DIR__.'/fixtures/other',
112 112
 
113 113
         ]);
114 114
 
Please login to merge, or discard this patch.
src/Views/tests/ContextProcessorTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@
 block discarded – undo
54 54
     protected function getSource(string $path): ViewSource
55 55
     {
56 56
         $loader = new ViewLoader([
57
-            'default' => __DIR__ . '/fixtures/default',
58
-            'other'   => __DIR__ . '/fixtures/other',
57
+            'default' => __DIR__.'/fixtures/default',
58
+            'other'   => __DIR__.'/fixtures/other',
59 59
         ]);
60 60
 
61 61
         return $loader->withExtension('php')->load($path);
Please login to merge, or discard this patch.
src/Views/tests/CacheTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,8 +130,8 @@
 block discarded – undo
130 130
     protected function getView(ContextInterface $context, string $path): ViewInterface
131 131
     {
132 132
         $loader = new ViewLoader([
133
-            'default' => __DIR__ . '/fixtures/default',
134
-            'other'   => __DIR__ . '/fixtures/other',
133
+            'default' => __DIR__.'/fixtures/default',
134
+            'other'   => __DIR__.'/fixtures/other',
135 135
         ]);
136 136
 
137 137
         $engine = new NativeEngine(new Container());
Please login to merge, or discard this patch.
src/Views/src/ViewContext.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     public function getID(): string
31 31
     {
32 32
         $calculated = '';
33
-        foreach ($this->dependencies as $dependency) {
33
+        foreach ($this->dependencies as $dependency){
34 34
             $calculated .= "[{$dependency->getName()}={$dependency->getValue()}]";
35 35
         }
36 36
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function resolveValue(string $dependency)
63 63
     {
64
-        if (!isset($this->dependencies[$dependency])) {
64
+        if (!isset($this->dependencies[$dependency])){
65 65
             throw new ContextException("Undefined context dependency '{$dependency}'.");
66 66
         }
67 67
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,8 @@  discard block
 block discarded – undo
30 30
     public function getID(): string
31 31
     {
32 32
         $calculated = '';
33
-        foreach ($this->dependencies as $dependency) {
33
+        foreach ($this->dependencies as $dependency)
34
+        {
34 35
             $calculated .= "[{$dependency->getName()}={$dependency->getValue()}]";
35 36
         }
36 37
 
@@ -61,7 +62,8 @@  discard block
 block discarded – undo
61 62
      */
62 63
     public function resolveValue(string $dependency)
63 64
     {
64
-        if (!isset($this->dependencies[$dependency])) {
65
+        if (!isset($this->dependencies[$dependency]))
66
+        {
65 67
             throw new ContextException("Undefined context dependency '{$dependency}'.");
66 68
         }
67 69
 
Please login to merge, or discard this patch.
src/Views/src/ViewManager.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
             'namespaces' => $config->getNamespaces()
45 45
         ]);
46 46
 
47
-        foreach ($this->config->getDependencies() as $dependency) {
47
+        foreach ($this->config->getDependencies() as $dependency){
48 48
             $this->addDependency($dependency->resolve($factory));
49 49
         }
50 50
 
51
-        foreach ($this->config->getEngines() as $engine) {
51
+        foreach ($this->config->getEngines() as $engine){
52 52
             $this->addEngine($engine->resolve($factory));
53 53
         }
54 54
 
55
-        if ($this->config->isCacheEnabled()) {
55
+        if ($this->config->isCacheEnabled()){
56 56
             $this->cache = new ViewCache();
57 57
         }
58 58
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         $this->engines[] = $engine->withLoader($this->loader);
86 86
 
87
-        uasort($this->engines, function (EngineInterface $a, EngineInterface $b) {
87
+        uasort($this->engines, function (EngineInterface $a, EngineInterface $b){
88 88
             return strcmp($a->getLoader()->getExtension(), $b->getLoader()->getExtension());
89 89
         });
90 90
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function compile(string $path): void
112 112
     {
113
-        if ($this->cache !== null) {
113
+        if ($this->cache !== null){
114 114
             $this->cache->resetPath($path);
115 115
         }
116 116
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
         // Rotate all possible context variants and warm up cache
120 120
         $generator = new ContextGenerator($this->context);
121
-        foreach ($generator->generate() as $context) {
121
+        foreach ($generator->generate() as $context){
122 122
             $engine->reset($path, $context);
123 123
             $engine->compile($path, $context);
124 124
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function reset(string $path): void
133 133
     {
134
-        if ($this->cache !== null) {
134
+        if ($this->cache !== null){
135 135
             $this->cache->resetPath($path);
136 136
         }
137 137
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         // Rotate all possible context variants and warm up cache
141 141
         $generator = new ContextGenerator($this->context);
142
-        foreach ($generator->generate() as $context) {
142
+        foreach ($generator->generate() as $context){
143 143
             $engine->reset($path, $context);
144 144
         }
145 145
     }
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function get(string $path): ViewInterface
156 156
     {
157
-        if ($this->cache !== null && $this->cache->has($this->context, $path)) {
157
+        if ($this->cache !== null && $this->cache->has($this->context, $path)){
158 158
             return $this->cache->get($this->context, $path);
159 159
         }
160 160
 
161 161
         $view = $this->findEngine($path)->get($path, $this->context);
162 162
 
163
-        if ($this->cache !== null) {
163
+        if ($this->cache !== null){
164 164
             $this->cache->set($this->context, $path, $view);
165 165
         }
166 166
 
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
      */
188 188
     protected function findEngine(string $path): EngineInterface
189 189
     {
190
-        foreach ($this->engines as $engine) {
191
-            if ($engine->getLoader()->exists($path)) {
190
+        foreach ($this->engines as $engine){
191
+            if ($engine->getLoader()->exists($path)){
192 192
                 return $engine;
193 193
             }
194 194
         }
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,15 +44,18 @@  discard block
 block discarded – undo
44 44
             'namespaces' => $config->getNamespaces()
45 45
         ]);
46 46
 
47
-        foreach ($this->config->getDependencies() as $dependency) {
47
+        foreach ($this->config->getDependencies() as $dependency)
48
+        {
48 49
             $this->addDependency($dependency->resolve($factory));
49 50
         }
50 51
 
51
-        foreach ($this->config->getEngines() as $engine) {
52
+        foreach ($this->config->getEngines() as $engine)
53
+        {
52 54
             $this->addEngine($engine->resolve($factory));
53 55
         }
54 56
 
55
-        if ($this->config->isCacheEnabled()) {
57
+        if ($this->config->isCacheEnabled())
58
+        {
56 59
             $this->cache = new ViewCache();
57 60
         }
58 61
     }
@@ -84,7 +87,8 @@  discard block
 block discarded – undo
84 87
     {
85 88
         $this->engines[] = $engine->withLoader($this->loader);
86 89
 
87
-        uasort($this->engines, function (EngineInterface $a, EngineInterface $b) {
90
+        uasort($this->engines, function (EngineInterface $a, EngineInterface $b)
91
+        {
88 92
             return strcmp($a->getLoader()->getExtension(), $b->getLoader()->getExtension());
89 93
         });
90 94
 
@@ -110,7 +114,8 @@  discard block
 block discarded – undo
110 114
      */
111 115
     public function compile(string $path): void
112 116
     {
113
-        if ($this->cache !== null) {
117
+        if ($this->cache !== null)
118
+        {
114 119
             $this->cache->resetPath($path);
115 120
         }
116 121
 
@@ -118,7 +123,8 @@  discard block
 block discarded – undo
118 123
 
119 124
         // Rotate all possible context variants and warm up cache
120 125
         $generator = new ContextGenerator($this->context);
121
-        foreach ($generator->generate() as $context) {
126
+        foreach ($generator->generate() as $context)
127
+        {
122 128
             $engine->reset($path, $context);
123 129
             $engine->compile($path, $context);
124 130
         }
@@ -131,7 +137,8 @@  discard block
 block discarded – undo
131 137
      */
132 138
     public function reset(string $path): void
133 139
     {
134
-        if ($this->cache !== null) {
140
+        if ($this->cache !== null)
141
+        {
135 142
             $this->cache->resetPath($path);
136 143
         }
137 144
 
@@ -139,7 +146,8 @@  discard block
 block discarded – undo
139 146
 
140 147
         // Rotate all possible context variants and warm up cache
141 148
         $generator = new ContextGenerator($this->context);
142
-        foreach ($generator->generate() as $context) {
149
+        foreach ($generator->generate() as $context)
150
+        {
143 151
             $engine->reset($path, $context);
144 152
         }
145 153
     }
@@ -154,13 +162,15 @@  discard block
 block discarded – undo
154 162
      */
155 163
     public function get(string $path): ViewInterface
156 164
     {
157
-        if ($this->cache !== null && $this->cache->has($this->context, $path)) {
165
+        if ($this->cache !== null && $this->cache->has($this->context, $path))
166
+        {
158 167
             return $this->cache->get($this->context, $path);
159 168
         }
160 169
 
161 170
         $view = $this->findEngine($path)->get($path, $this->context);
162 171
 
163
-        if ($this->cache !== null) {
172
+        if ($this->cache !== null)
173
+        {
164 174
             $this->cache->set($this->context, $path, $view);
165 175
         }
166 176
 
@@ -187,8 +197,10 @@  discard block
 block discarded – undo
187 197
      */
188 198
     protected function findEngine(string $path): EngineInterface
189 199
     {
190
-        foreach ($this->engines as $engine) {
191
-            if ($engine->getLoader()->exists($path)) {
200
+        foreach ($this->engines as $engine)
201
+        {
202
+            if ($engine->getLoader()->exists($path))
203
+            {
192 204
                 return $engine;
193 205
             }
194 206
         }
Please login to merge, or discard this patch.
src/Views/src/Traits/ProcessorTrait.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
      */
30 30
     private function process(ViewSource $source, ContextInterface $context): ViewSource
31 31
     {
32
-        foreach ($this->processors as $processor) {
32
+        foreach ($this->processors as $processor){
33 33
             $source = $processor->process($source, $context);
34 34
         }
35 35
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@
 block discarded – undo
29 29
      */
30 30
     private function process(ViewSource $source, ContextInterface $context): ViewSource
31 31
     {
32
-        foreach ($this->processors as $processor) {
32
+        foreach ($this->processors as $processor)
33
+        {
33 34
             $source = $processor->process($source, $context);
34 35
         }
35 36
 
Please login to merge, or discard this patch.
src/Views/src/Config/ViewsConfig.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function getCacheDirectory(): string
48 48
     {
49
-        return rtrim($this->config['cache']['directory'], '/') . '/';
49
+        return rtrim($this->config['cache']['directory'], '/').'/';
50 50
     }
51 51
 
52 52
     /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     public function getDependencies(): array
70 70
     {
71 71
         $dependencies = [];
72
-        foreach ($this->config['dependencies'] as $dependency) {
72
+        foreach ($this->config['dependencies'] as $dependency){
73 73
             $dependencies[] = $this->wire($dependency);
74 74
         }
75 75
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     public function getEngines(): array
87 87
     {
88 88
         $engines = [];
89
-        foreach ($this->config['engines'] as $engine) {
89
+        foreach ($this->config['engines'] as $engine){
90 90
             $engines[] = $this->wire($engine);
91 91
         }
92 92
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
      */
102 102
     private function wire($item): Autowire
103 103
     {
104
-        if ($item instanceof Autowire) {
104
+        if ($item instanceof Autowire){
105 105
             return $item;
106 106
         }
107 107
 
108
-        if (is_string($item)) {
108
+        if (is_string($item)){
109 109
             return new Autowire($item);
110 110
         }
111 111
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,7 +69,8 @@  discard block
 block discarded – undo
69 69
     public function getDependencies(): array
70 70
     {
71 71
         $dependencies = [];
72
-        foreach ($this->config['dependencies'] as $dependency) {
72
+        foreach ($this->config['dependencies'] as $dependency)
73
+        {
73 74
             $dependencies[] = $this->wire($dependency);
74 75
         }
75 76
 
@@ -86,7 +87,8 @@  discard block
 block discarded – undo
86 87
     public function getEngines(): array
87 88
     {
88 89
         $engines = [];
89
-        foreach ($this->config['engines'] as $engine) {
90
+        foreach ($this->config['engines'] as $engine)
91
+        {
90 92
             $engines[] = $this->wire($engine);
91 93
         }
92 94
 
@@ -101,11 +103,13 @@  discard block
 block discarded – undo
101 103
      */
102 104
     private function wire($item): Autowire
103 105
     {
104
-        if ($item instanceof Autowire) {
106
+        if ($item instanceof Autowire)
107
+        {
105 108
             return $item;
106 109
         }
107 110
 
108
-        if (is_string($item)) {
111
+        if (is_string($item))
112
+        {
109 113
             return new Autowire($item);
110 114
         }
111 115
 
Please login to merge, or discard this patch.