Passed
Pull Request — master (#839)
by Alexander
16:59
created
src/Views/src/Bootloader/ViewsBootloader.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function __construct(
36 36
         private readonly ConfiguratorInterface $config
37
-    ) {
37
+    ){
38 38
     }
39 39
 
40 40
     public function init(EnvironmentInterface $env, DirectoriesInterface $dirs, DebugMode $debugMode): void
41 41
     {
42
-        if (!$dirs->has('views')) {
43
-            $dirs->set('views', $dirs->get('app') . 'views');
42
+        if (!$dirs->has('views')){
43
+            $dirs->set('views', $dirs->get('app').'views');
44 44
         }
45 45
 
46 46
         // default view config
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             [
50 50
                 'cache' => [
51 51
                     'enabled' => $env->get('VIEW_CACHE', !$debugMode->isEnabled()),
52
-                    'directory' => $dirs->get('cache') . 'views',
52
+                    'directory' => $dirs->get('cache').'views',
53 53
                 ],
54 54
                 'namespaces' => [
55 55
                     'default' => [$dirs->get('views')],
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 
63 63
     public function addDirectory(string $namespace, string $directory): void
64 64
     {
65
-        if (!isset($this->config->getConfig(ViewsConfig::CONFIG)['namespaces'][$namespace])) {
65
+        if (!isset($this->config->getConfig(ViewsConfig::CONFIG)['namespaces'][$namespace])){
66 66
             $this->config->modify(ViewsConfig::CONFIG, new Append('namespaces', $namespace, []));
67 67
         }
68 68
 
69 69
         $this->config->modify(
70 70
             ViewsConfig::CONFIG,
71
-            new Append('namespaces.' . $namespace, null, $directory)
71
+            new Append('namespaces.'.$namespace, null, $directory)
72 72
         );
73 73
     }
74 74
 
75
-    public function addEngine(string|EngineInterface $engine): void
75
+    public function addEngine(string | EngineInterface $engine): void
76 76
     {
77 77
         $this->config->modify(
78 78
             ViewsConfig::CONFIG,
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         );
81 81
     }
82 82
 
83
-    public function addCacheDependency(string|DependencyInterface $dependency): void
83
+    public function addCacheDependency(string | DependencyInterface $dependency): void
84 84
     {
85 85
         $this->config->modify(
86 86
             ViewsConfig::CONFIG,
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,8 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function init(EnvironmentInterface $env, DirectoriesInterface $dirs, DebugMode $debugMode): void
41 41
     {
42
-        if (!$dirs->has('views')) {
42
+        if (!$dirs->has('views'))
43
+        {
43 44
             $dirs->set('views', $dirs->get('app') . 'views');
44 45
         }
45 46
 
@@ -62,7 +63,8 @@  discard block
 block discarded – undo
62 63
 
63 64
     public function addDirectory(string $namespace, string $directory): void
64 65
     {
65
-        if (!isset($this->config->getConfig(ViewsConfig::CONFIG)['namespaces'][$namespace])) {
66
+        if (!isset($this->config->getConfig(ViewsConfig::CONFIG)['namespaces'][$namespace]))
67
+        {
66 68
             $this->config->modify(ViewsConfig::CONFIG, new Append('namespaces', $namespace, []));
67 69
         }
68 70
 
Please login to merge, or discard this patch.
src/Hmvc/tests/DemoInterceptor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,6 +11,6 @@
 block discarded – undo
11 11
 {
12 12
     public function process(string $controller, string $action, array $parameters, CoreInterface $core): string
13 13
     {
14
-        return '?' . $core->callAction($controller, $action, $parameters) . '!';
14
+        return '?'.$core->callAction($controller, $action, $parameters).'!';
15 15
     }
16 16
 }
Please login to merge, or discard this patch.
src/Hmvc/tests/InterceptorPipelineTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 {
16 16
     public function testInterceptorCallingEventShouldBeDispatched(): void
17 17
     {
18
-        $interceptor = new class implements CoreInterceptorInterface {
18
+        $interceptor = new class implements CoreInterceptorInterface{
19 19
             public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed
20 20
             {
21 21
                 return null;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $pipeline = new InterceptorPipeline($dispatcher);
32 32
         $pipeline->addInterceptor($interceptor);
33 33
 
34
-        $pipeline->withCore(new class implements CoreInterface {
34
+        $pipeline->withCore(new class implements CoreInterface{
35 35
             public function callAction(string $controller, string $action, array $parameters = []): mixed
36 36
             {
37 37
                 return null;
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 {
16 16
     public function testInterceptorCallingEventShouldBeDispatched(): void
17 17
     {
18
-        $interceptor = new class implements CoreInterceptorInterface {
18
+        $interceptor = new class implements CoreInterceptorInterface
19
+        {
19 20
             public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed
20 21
             {
21 22
                 return null;
@@ -31,7 +32,8 @@  discard block
 block discarded – undo
31 32
         $pipeline = new InterceptorPipeline($dispatcher);
32 33
         $pipeline->addInterceptor($interceptor);
33 34
 
34
-        $pipeline->withCore(new class implements CoreInterface {
35
+        $pipeline->withCore(new class implements CoreInterface
36
+        {
35 37
             public function callAction(string $controller, string $action, array $parameters = []): mixed
36 38
             {
37 39
                 return null;
Please login to merge, or discard this patch.
src/Hmvc/src/InterceptorPipeline.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function __construct(
24 24
         private readonly ?EventDispatcherInterface $dispatcher = null
25
-    ) {
25
+    ){
26 26
     }
27 27
 
28 28
     public function addInterceptor(CoreInterceptorInterface $interceptor): void
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function callAction(string $controller, string $action, array $parameters = []): mixed
45 45
     {
46
-        if ($this->core === null) {
46
+        if ($this->core === null){
47 47
             throw new InterceptorException('Unable to invoke pipeline without assigned core');
48 48
         }
49 49
 
50 50
         $position = $this->position++;
51
-        if (isset($this->interceptors[$position])) {
51
+        if (isset($this->interceptors[$position])){
52 52
             $interceptor = $this->interceptors[$position];
53 53
             $this->dispatcher?->dispatch(new InterceptorCalling(
54 54
                 controller: $controller,
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,12 +43,14 @@
 block discarded – undo
43 43
      */
44 44
     public function callAction(string $controller, string $action, array $parameters = []): mixed
45 45
     {
46
-        if ($this->core === null) {
46
+        if ($this->core === null)
47
+        {
47 48
             throw new InterceptorException('Unable to invoke pipeline without assigned core');
48 49
         }
49 50
 
50 51
         $position = $this->position++;
51
-        if (isset($this->interceptors[$position])) {
52
+        if (isset($this->interceptors[$position]))
53
+        {
52 54
             $interceptor = $this->interceptors[$position];
53 55
             $this->dispatcher?->dispatch(new InterceptorCalling(
54 56
                 controller: $controller,
Please login to merge, or discard this patch.
src/Hmvc/src/InterceptableCore.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 CoreInterface $core,
18 18
         ?EventDispatcherInterface $dispatcher = null
19
-    ) {
19
+    ){
20 20
         $this->pipeline = new InterceptorPipeline($dispatcher);
21 21
     }
22 22
 
Please login to merge, or discard this patch.
src/Hmvc/src/Event/InterceptorCalling.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,6 +13,6 @@
 block discarded – undo
13 13
         public readonly string $action,
14 14
         public readonly array $parameters,
15 15
         public readonly CoreInterceptorInterface $interceptor
16
-    ) {
16
+    ){
17 17
     }
18 18
 }
Please login to merge, or discard this patch.
src/Hmvc/src/AbstractCore.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
     public function __construct(
25 25
         /** @internal */
26 26
         protected ContainerInterface $container
27
-    ) {
27
+    ){
28 28
         // resolver is usually the container itself
29 29
         $this->resolver = $container->get(ResolverInterface::class);
30 30
     }
31 31
 
32 32
     public function callAction(string $controller, string $action, array $parameters = []): mixed
33 33
     {
34
-        try {
34
+        try{
35 35
             $method = new \ReflectionMethod($controller, $action);
36
-        } catch (\ReflectionException $e) {
36
+        }catch (\ReflectionException $e){
37 37
             throw new ControllerException(
38 38
                 \sprintf('Invalid action `%s`->`%s`', $controller, $action),
39 39
                 ControllerException::BAD_ACTION,
@@ -41,23 +41,23 @@  discard block
 block discarded – undo
41 41
             );
42 42
         }
43 43
 
44
-        if ($method->isStatic() || !$method->isPublic()) {
44
+        if ($method->isStatic() || !$method->isPublic()){
45 45
             throw new ControllerException(
46 46
                 \sprintf('Invalid action `%s`->`%s`', $controller, $action),
47 47
                 ControllerException::BAD_ACTION
48 48
             );
49 49
         }
50 50
 
51
-        try {
51
+        try{
52 52
             // getting the set of arguments should be sent to requested method
53 53
             $args = $this->resolver->resolveArguments($method, $parameters, validate: true);
54
-        } catch (ArgumentResolvingException|InvalidArgumentException $e) {
54
+        }catch (ArgumentResolvingException | InvalidArgumentException $e){
55 55
             throw new ControllerException(
56 56
                 \sprintf('Missing/invalid parameter %s of `%s`->`%s`', $e->getParameter(), $controller, $action),
57 57
                 ControllerException::BAD_ARGUMENT,
58 58
                 $e
59 59
             );
60
-        } catch (ContainerExceptionInterface $e) {
60
+        }catch (ContainerExceptionInterface $e){
61 61
             throw new ControllerException(
62 62
                 $e->getMessage(),
63 63
                 ControllerException::ERROR,
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,9 +31,12 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function callAction(string $controller, string $action, array $parameters = []): mixed
33 33
     {
34
-        try {
34
+        try
35
+        {
35 36
             $method = new \ReflectionMethod($controller, $action);
36
-        } catch (\ReflectionException $e) {
37
+        }
38
+        catch (\ReflectionException $e)
39
+        {
37 40
             throw new ControllerException(
38 41
                 \sprintf('Invalid action `%s`->`%s`', $controller, $action),
39 42
                 ControllerException::BAD_ACTION,
@@ -41,23 +44,29 @@  discard block
 block discarded – undo
41 44
             );
42 45
         }
43 46
 
44
-        if ($method->isStatic() || !$method->isPublic()) {
47
+        if ($method->isStatic() || !$method->isPublic())
48
+        {
45 49
             throw new ControllerException(
46 50
                 \sprintf('Invalid action `%s`->`%s`', $controller, $action),
47 51
                 ControllerException::BAD_ACTION
48 52
             );
49 53
         }
50 54
 
51
-        try {
55
+        try
56
+        {
52 57
             // getting the set of arguments should be sent to requested method
53 58
             $args = $this->resolver->resolveArguments($method, $parameters, validate: true);
54
-        } catch (ArgumentResolvingException|InvalidArgumentException $e) {
59
+        }
60
+        catch (ArgumentResolvingException|InvalidArgumentException $e)
61
+        {
55 62
             throw new ControllerException(
56 63
                 \sprintf('Missing/invalid parameter %s of `%s`->`%s`', $e->getParameter(), $controller, $action),
57 64
                 ControllerException::BAD_ARGUMENT,
58 65
                 $e
59 66
             );
60
-        } catch (ContainerExceptionInterface $e) {
67
+        }
68
+        catch (ContainerExceptionInterface $e)
69
+        {
61 70
             throw new ControllerException(
62 71
                 $e->getMessage(),
63 72
                 ControllerException::ERROR,
Please login to merge, or discard this patch.
src/Pagination/src/Paginator.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
         private int $limit = 25,
17 17
         private int $count = 0,
18 18
         private readonly ?string $parameter = null
19
-    ) {
19
+    ){
20 20
     }
21 21
 
22 22
     /**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public function paginate(PaginableInterface $target): PaginatorInterface
72 72
     {
73 73
         $paginator = clone $this;
74
-        if ($target instanceof \Countable && $paginator->count === 0) {
74
+        if ($target instanceof \Countable && $paginator->count === 0){
75 75
             $paginator->setCount($target->count());
76 76
         }
77 77
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
     public function countDisplayed(): int
95 95
     {
96
-        if ($this->getPage() === $this->countPages) {
96
+        if ($this->getPage() === $this->countPages){
97 97
             return $this->count - $this->getOffset();
98 98
         }
99 99
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
     public function nextPage(): ?int
109 109
     {
110
-        if ($this->getPage() !== $this->countPages) {
110
+        if ($this->getPage() !== $this->countPages){
111 111
             return $this->getPage() + 1;
112 112
         }
113 113
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
     public function previousPage(): ?int
118 118
     {
119
-        if ($this->getPage() > 1) {
119
+        if ($this->getPage() > 1){
120 120
             return $this->getPage() - 1;
121 121
         }
122 122
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     private function setCount(int $count): self
130 130
     {
131 131
         $this->count = \max($count, 0);
132
-        $this->countPages = $this->count > 0 ? (int) \ceil($this->count / $this->limit) : 1;
132
+        $this->countPages = $this->count > 0 ? (int)\ceil($this->count / $this->limit) : 1;
133 133
 
134 134
         return $this;
135 135
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,7 +71,8 @@  discard block
 block discarded – undo
71 71
     public function paginate(PaginableInterface $target): PaginatorInterface
72 72
     {
73 73
         $paginator = clone $this;
74
-        if ($target instanceof \Countable && $paginator->count === 0) {
74
+        if ($target instanceof \Countable && $paginator->count === 0)
75
+        {
75 76
             $paginator->setCount($target->count());
76 77
         }
77 78
 
@@ -93,7 +94,8 @@  discard block
 block discarded – undo
93 94
 
94 95
     public function countDisplayed(): int
95 96
     {
96
-        if ($this->getPage() === $this->countPages) {
97
+        if ($this->getPage() === $this->countPages)
98
+        {
97 99
             return $this->count - $this->getOffset();
98 100
         }
99 101
 
@@ -107,7 +109,8 @@  discard block
 block discarded – undo
107 109
 
108 110
     public function nextPage(): ?int
109 111
     {
110
-        if ($this->getPage() !== $this->countPages) {
112
+        if ($this->getPage() !== $this->countPages)
113
+        {
111 114
             return $this->getPage() + 1;
112 115
         }
113 116
 
@@ -116,7 +119,8 @@  discard block
 block discarded – undo
116 119
 
117 120
     public function previousPage(): ?int
118 121
     {
119
-        if ($this->getPage() > 1) {
122
+        if ($this->getPage() > 1)
123
+        {
120 124
             return $this->getPage() - 1;
121 125
         }
122 126
 
Please login to merge, or discard this patch.
src/Boot/tests/MemoryTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@  discard block
 block discarded – undo
14 14
     {
15 15
         $core = TestCore::create([
16 16
             'root'  => __DIR__,
17
-            'cache' => __DIR__ . '/cache'
17
+            'cache' => __DIR__.'/cache'
18 18
         ])->run();
19 19
 
20 20
         /** @var MemoryInterface $memory */
21 21
         $memory = $core->getContainer()->get(MemoryInterface::class);
22 22
 
23 23
         $memory->saveData('test', 'data');
24
-        $this->assertFileExists(__DIR__ . '/cache/test.php');
24
+        $this->assertFileExists(__DIR__.'/cache/test.php');
25 25
         $this->assertSame('data', $memory->loadData('test'));
26 26
 
27
-        unlink(__DIR__ . '/cache/test.php');
27
+        unlink(__DIR__.'/cache/test.php');
28 28
         $this->assertNull($memory->loadData('test'));
29 29
     }
30 30
 
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $core = TestCore::create([
34 34
             'root'  => __DIR__,
35
-            'cache' => __DIR__ . '/cache'
35
+            'cache' => __DIR__.'/cache'
36 36
         ])->run();
37 37
 
38 38
         /** @var MemoryInterface $memory */
39 39
         $memory = $core->getContainer()->get(MemoryInterface::class);
40 40
 
41
-        file_put_contents(__DIR__ . '/cache/test.php', '<?php broken');
41
+        file_put_contents(__DIR__.'/cache/test.php', '<?php broken');
42 42
         $this->assertNull($memory->loadData('test'));
43 43
 
44
-        unlink(__DIR__ . '/cache/test.php');
44
+        unlink(__DIR__.'/cache/test.php');
45 45
         $this->assertNull($memory->loadData('test'));
46 46
     }
47 47
 }
Please login to merge, or discard this patch.