Passed
Pull Request — master (#1115)
by Maxim
22:29
created
src/Views/src/ViewContext.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function getID(): string
21 21
     {
22 22
         $calculated = '';
23
-        foreach ($this->dependencies as $dependency) {
23
+        foreach ($this->dependencies as $dependency){
24 24
             $calculated .= \sprintf('[%s=%s]', $dependency->getName(), $dependency->getValue());
25 25
         }
26 26
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function resolveValue(string $dependency): mixed
49 49
     {
50
-        if (!isset($this->dependencies[$dependency])) {
50
+        if (!isset($this->dependencies[$dependency])){
51 51
             throw new ContextException(\sprintf('Undefined context dependency \'%s\'.', $dependency));
52 52
         }
53 53
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
     public function getID(): string
21 21
     {
22 22
         $calculated = '';
23
-        foreach ($this->dependencies as $dependency) {
23
+        foreach ($this->dependencies as $dependency)
24
+        {
24 25
             $calculated .= \sprintf('[%s=%s]', $dependency->getName(), $dependency->getValue());
25 26
         }
26 27
 
@@ -47,7 +48,8 @@  discard block
 block discarded – undo
47 48
 
48 49
     public function resolveValue(string $dependency): mixed
49 50
     {
50
-        if (!isset($this->dependencies[$dependency])) {
51
+        if (!isset($this->dependencies[$dependency]))
52
+        {
51 53
             throw new ContextException(\sprintf('Undefined context dependency \'%s\'.', $dependency));
52 54
         }
53 55
 
Please login to merge, or discard this patch.
src/Views/src/Engine/AbstractEngine.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 
29 29
     public function getLoader(): LoaderInterface
30 30
     {
31
-        if (empty($this->loader)) {
31
+        if (empty($this->loader)){
32 32
             throw new EngineException('No associated loader found');
33 33
         }
34 34
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,8 @@
 block discarded – undo
28 28
 
29 29
     public function getLoader(): LoaderInterface
30 30
     {
31
-        if (empty($this->loader)) {
31
+        if (empty($this->loader))
32
+        {
32 33
             throw new EngineException('No associated loader found');
33 34
         }
34 35
 
Please login to merge, or discard this patch.
src/Views/src/Engine/Native/NativeEngine.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     public function __construct(
17 17
         private readonly ContainerInterface $container,
18 18
         string $extension = self::EXTENSION
19
-    ) {
19
+    ){
20 20
         $this->extension = $extension;
21 21
     }
22 22
 
Please login to merge, or discard this patch.
src/Views/src/Engine/Native/NativeView.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     public function __construct(
16 16
         private readonly ViewSource $view,
17 17
         private readonly ContainerInterface $container
18
-    ) {
18
+    ){
19 19
     }
20 20
 
21 21
     public function render(array $data = []): string
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
         \ob_start();
24 24
         $__outputLevel__ = \ob_get_level();
25 25
 
26
-        try {
26
+        try{
27 27
             ContainerScope::runScope($this->container, function () use ($data): void {
28 28
                 \extract($data, EXTR_OVERWRITE);
29 29
                 // render view in context and output buffer scope, context can be accessed using $this->context
30 30
                 require $this->view->getFilename();
31 31
             });
32
-        } catch (\Throwable $throwable) {
33
-            while (\ob_get_level() >= $__outputLevel__) {
32
+        }catch (\Throwable $throwable){
33
+            while (\ob_get_level() >= $__outputLevel__){
34 34
                 \ob_end_clean();
35 35
             }
36 36
 
37 37
             throw new RenderException($throwable);
38
-        } finally {
38
+        }finally{
39 39
             //Closing all nested buffers
40
-            while (\ob_get_level() > $__outputLevel__) {
40
+            while (\ob_get_level() > $__outputLevel__){
41 41
                 \ob_end_clean();
42 42
             }
43 43
         }
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,21 +23,28 @@
 block discarded – undo
23 23
         \ob_start();
24 24
         $__outputLevel__ = \ob_get_level();
25 25
 
26
-        try {
26
+        try
27
+        {
27 28
             ContainerScope::runScope($this->container, function () use ($data): void {
28 29
                 \extract($data, EXTR_OVERWRITE);
29 30
                 // render view in context and output buffer scope, context can be accessed using $this->context
30 31
                 require $this->view->getFilename();
31 32
             });
32
-        } catch (\Throwable $throwable) {
33
-            while (\ob_get_level() >= $__outputLevel__) {
33
+        }
34
+        catch (\Throwable $throwable)
35
+        {
36
+            while (\ob_get_level() >= $__outputLevel__)
37
+            {
34 38
                 \ob_end_clean();
35 39
             }
36 40
 
37 41
             throw new RenderException($throwable);
38
-        } finally {
42
+        }
43
+        finally
44
+        {
39 45
             //Closing all nested buffers
40
-            while (\ob_get_level() > $__outputLevel__) {
46
+            while (\ob_get_level() > $__outputLevel__)
47
+            {
41 48
                 \ob_end_clean();
42 49
             }
43 50
         }
Please login to merge, or discard this patch.
src/Views/src/ViewManager.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
         private readonly GlobalVariablesInterface $globalVariables,
23 23
         FactoryInterface $factory,
24 24
         ?ContextInterface $context = null
25
-    ) {
25
+    ){
26 26
         $this->context = $context ?? new ViewContext();
27 27
         $this->loader = $factory->make(LoaderInterface::class, [
28 28
             'namespaces' => $config->getNamespaces(),
29 29
         ]);
30 30
 
31
-        foreach ($this->config->getDependencies() as $dependency) {
31
+        foreach ($this->config->getDependencies() as $dependency){
32 32
             $this->addDependency($dependency->resolve($factory));
33 33
         }
34 34
 
35
-        foreach ($this->config->getEngines() as $engine) {
35
+        foreach ($this->config->getEngines() as $engine){
36 36
             $this->addEngine($engine->resolve($factory));
37 37
         }
38 38
 
39
-        if ($this->config->isCacheEnabled()) {
39
+        if ($this->config->isCacheEnabled()){
40 40
             $this->cache = new ViewCache();
41 41
         }
42 42
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     {
62 62
         $this->engines[] = $engine->withLoader($this->loader);
63 63
 
64
-        \uasort($this->engines, static function (EngineInterface $a, EngineInterface $b) {
64
+        \uasort($this->engines, static function (EngineInterface $a, EngineInterface $b){
65 65
             return \strcmp(
66 66
                 $a->getLoader()->getExtension() ?? '',
67 67
                 $b->getLoader()->getExtension() ?? ''
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         // Rotate all possible context variants and warm up cache
97 97
         $generator = new ContextGenerator($this->context);
98
-        foreach ($generator->generate() as $context) {
98
+        foreach ($generator->generate() as $context){
99 99
             $engine->reset($path, $context);
100 100
             $engine->compile($path, $context);
101 101
         }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
         // Rotate all possible context variants and warm up cache
114 114
         $generator = new ContextGenerator($this->context);
115
-        foreach ($generator->generate() as $context) {
115
+        foreach ($generator->generate() as $context){
116 116
             $engine->reset($path, $context);
117 117
         }
118 118
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function get(string $path): ViewInterface
126 126
     {
127
-        if ($this->cache?->has($this->context, $path)) {
127
+        if ($this->cache?->has($this->context, $path)){
128 128
             return $this->cache->get($this->context, $path);
129 129
         }
130 130
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
      */
154 154
     private function findEngine(string $path): EngineInterface
155 155
     {
156
-        foreach ($this->engines as $engine) {
157
-            if ($engine->getLoader()->exists($path)) {
156
+        foreach ($this->engines as $engine){
157
+            if ($engine->getLoader()->exists($path)){
158 158
                 return $engine;
159 159
             }
160 160
         }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,15 +28,18 @@  discard block
 block discarded – undo
28 28
             'namespaces' => $config->getNamespaces(),
29 29
         ]);
30 30
 
31
-        foreach ($this->config->getDependencies() as $dependency) {
31
+        foreach ($this->config->getDependencies() as $dependency)
32
+        {
32 33
             $this->addDependency($dependency->resolve($factory));
33 34
         }
34 35
 
35
-        foreach ($this->config->getEngines() as $engine) {
36
+        foreach ($this->config->getEngines() as $engine)
37
+        {
36 38
             $this->addEngine($engine->resolve($factory));
37 39
         }
38 40
 
39
-        if ($this->config->isCacheEnabled()) {
41
+        if ($this->config->isCacheEnabled())
42
+        {
40 43
             $this->cache = new ViewCache();
41 44
         }
42 45
     }
@@ -61,7 +64,8 @@  discard block
 block discarded – undo
61 64
     {
62 65
         $this->engines[] = $engine->withLoader($this->loader);
63 66
 
64
-        \uasort($this->engines, static function (EngineInterface $a, EngineInterface $b) {
67
+        \uasort($this->engines, static function (EngineInterface $a, EngineInterface $b)
68
+        {
65 69
             return \strcmp(
66 70
                 $a->getLoader()->getExtension() ?? '',
67 71
                 $b->getLoader()->getExtension() ?? ''
@@ -95,7 +99,8 @@  discard block
 block discarded – undo
95 99
 
96 100
         // Rotate all possible context variants and warm up cache
97 101
         $generator = new ContextGenerator($this->context);
98
-        foreach ($generator->generate() as $context) {
102
+        foreach ($generator->generate() as $context)
103
+        {
99 104
             $engine->reset($path, $context);
100 105
             $engine->compile($path, $context);
101 106
         }
@@ -112,7 +117,8 @@  discard block
 block discarded – undo
112 117
 
113 118
         // Rotate all possible context variants and warm up cache
114 119
         $generator = new ContextGenerator($this->context);
115
-        foreach ($generator->generate() as $context) {
120
+        foreach ($generator->generate() as $context)
121
+        {
116 122
             $engine->reset($path, $context);
117 123
         }
118 124
     }
@@ -124,7 +130,8 @@  discard block
 block discarded – undo
124 130
      */
125 131
     public function get(string $path): ViewInterface
126 132
     {
127
-        if ($this->cache?->has($this->context, $path)) {
133
+        if ($this->cache?->has($this->context, $path))
134
+        {
128 135
             return $this->cache->get($this->context, $path);
129 136
         }
130 137
 
@@ -153,8 +160,10 @@  discard block
 block discarded – undo
153 160
      */
154 161
     private function findEngine(string $path): EngineInterface
155 162
     {
156
-        foreach ($this->engines as $engine) {
157
-            if ($engine->getLoader()->exists($path)) {
163
+        foreach ($this->engines as $engine)
164
+        {
165
+            if ($engine->getLoader()->exists($path))
166
+            {
158 167
                 return $engine;
159 168
             }
160 169
         }
Please login to merge, or discard this patch.
src/Views/src/ViewSource.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
         private readonly string $filename,
16 16
         private readonly string $namespace,
17 17
         private readonly string $name
18
-    ) {
18
+    ){
19 19
     }
20 20
 
21 21
     /**
Please login to merge, or discard this patch.
src/Views/src/Exception/RenderException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@
 block discarded – undo
10 10
 
11 11
     public function __construct(\Throwable $previous = null)
12 12
     {
13
-        parent::__construct((string) $previous?->getMessage(), (int) ($previous?->getCode() ?? 0), $previous);
14
-        $this->file = (string) $previous?->getFile();
15
-        $this->line = (int) $previous?->getLine();
13
+        parent::__construct((string)$previous?->getMessage(), (int)($previous?->getCode() ?? 0), $previous);
14
+        $this->file = (string)$previous?->getFile();
15
+        $this->line = (int)$previous?->getLine();
16 16
     }
17 17
 
18 18
     /**
Please login to merge, or discard this patch.
src/Views/src/Exception/CompileException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
 
11 11
     public function __construct(\Throwable $previous = null)
12 12
     {
13
-        parent::__construct((string) $previous?->getMessage(), (int) ($previous?->getCode() ?? 0), $previous);
13
+        parent::__construct((string)$previous?->getMessage(), (int)($previous?->getCode() ?? 0), $previous);
14 14
 
15
-        $this->file = (string) $previous?->getFile();
16
-        $this->line = (int) $previous?->getLine();
15
+        $this->file = (string)$previous?->getFile();
16
+        $this->line = (int)$previous?->getLine();
17 17
     }
18 18
 
19 19
     /**
Please login to merge, or discard this patch.
src/Views/src/Context/ValueDependency.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
         private readonly string $name,
18 18
         private mixed $value,
19 19
         array $variants = null
20
-    ) {
20
+    ){
21 21
         $this->variants = $variants ?? [$value];
22 22
     }
23 23
 
Please login to merge, or discard this patch.