Passed
Pull Request — master (#600)
by Aleksei
08:16 queued 03:02
created
src/Boot/tests/MemoryTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
     {
22 22
         $core = TestCore::init([
23 23
             'root'  => __DIR__,
24
-            'cache' => __DIR__ . '/cache'
24
+            'cache' => __DIR__.'/cache'
25 25
         ]);
26 26
 
27 27
         /** @var MemoryInterface $memory */
28 28
         $memory = $core->getContainer()->get(MemoryInterface::class);
29 29
 
30 30
         $memory->saveData('test', 'data');
31
-        $this->assertFileExists(__DIR__ . '/cache/test.php');
31
+        $this->assertFileExists(__DIR__.'/cache/test.php');
32 32
         $this->assertSame('data', $memory->loadData('test'));
33 33
 
34
-        unlink(__DIR__ . '/cache/test.php');
34
+        unlink(__DIR__.'/cache/test.php');
35 35
         $this->assertNull($memory->loadData('test'));
36 36
     }
37 37
 
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
     {
40 40
         $core = TestCore::init([
41 41
             'root'  => __DIR__,
42
-            'cache' => __DIR__ . '/cache'
42
+            'cache' => __DIR__.'/cache'
43 43
         ]);
44 44
 
45 45
         /** @var MemoryInterface $memory */
46 46
         $memory = $core->getContainer()->get(MemoryInterface::class);
47 47
 
48
-        file_put_contents(__DIR__ . '/cache/test.php', '<?php broken');
48
+        file_put_contents(__DIR__.'/cache/test.php', '<?php broken');
49 49
         $this->assertNull($memory->loadData('test'));
50 50
 
51
-        unlink(__DIR__ . '/cache/test.php');
51
+        unlink(__DIR__.'/cache/test.php');
52 52
         $this->assertNull($memory->loadData('test'));
53 53
     }
54 54
 }
Please login to merge, or discard this patch.
src/Boot/tests/Fixtures/BrokenCore.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,25 +29,25 @@
 block discarded – undo
29 29
      */
30 30
     protected function mapDirectories(array $directories): array
31 31
     {
32
-        if (!isset($directories['root'])) {
32
+        if (!isset($directories['root'])){
33 33
             throw new BootException('Missing required directory `root`.');
34 34
         }
35 35
 
36
-        if (!isset($directories['app'])) {
37
-            $directories['app'] = $directories['root'] . '/app/';
36
+        if (!isset($directories['app'])){
37
+            $directories['app'] = $directories['root'].'/app/';
38 38
         }
39 39
 
40 40
         return array_merge([
41 41
             // public root
42
-            'public' => $directories['root'] . '/public/',
42
+            'public' => $directories['root'].'/public/',
43 43
 
44 44
             // data directories
45
-            'runtime' => $directories['root'] . '/runtime/',
46
-            'cache' => $directories['root'] . '/runtime/cache/',
45
+            'runtime' => $directories['root'].'/runtime/',
46
+            'cache' => $directories['root'].'/runtime/cache/',
47 47
 
48 48
             // application directories
49
-            'config' => $directories['app'] . '/config/',
50
-            'resources' => $directories['app'] . '/resources/',
49
+            'config' => $directories['app'].'/config/',
50
+            'resources' => $directories['app'].'/resources/',
51 51
         ], $directories);
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
@@ -43,11 +43,13 @@
 block discarded – undo
43 43
      */
44 44
     protected function mapDirectories(array $directories): array
45 45
     {
46
-        if (!isset($directories['root'])) {
46
+        if (!isset($directories['root']))
47
+        {
47 48
             throw new BootException('Missing required directory `root`.');
48 49
         }
49 50
 
50
-        if (!isset($directories['app'])) {
51
+        if (!isset($directories['app']))
52
+        {
51 53
             $directories['app'] = $directories['root'] . '/app/';
52 54
         }
53 55
 
Please login to merge, or discard this patch.
src/Boot/tests/Fixtures/TestCore.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,25 +35,25 @@
 block discarded – undo
35 35
      */
36 36
     protected function mapDirectories(array $directories): array
37 37
     {
38
-        if (!isset($directories['root'])) {
38
+        if (!isset($directories['root'])){
39 39
             throw new BootException('Missing required directory `root`.');
40 40
         }
41 41
 
42
-        if (!isset($directories['app'])) {
43
-            $directories['app'] = $directories['root'] . '/app/';
42
+        if (!isset($directories['app'])){
43
+            $directories['app'] = $directories['root'].'/app/';
44 44
         }
45 45
 
46 46
         return array_merge([
47 47
             // public root
48
-            'public'    => $directories['root'] . '/public/',
48
+            'public'    => $directories['root'].'/public/',
49 49
 
50 50
             // data directories
51
-            'runtime'   => $directories['root'] . '/runtime/',
52
-            'cache'     => $directories['root'] . '/runtime/cache/',
51
+            'runtime'   => $directories['root'].'/runtime/',
52
+            'cache'     => $directories['root'].'/runtime/cache/',
53 53
 
54 54
             // application directories
55
-            'config'    => $directories['app'] . '/config/',
56
-            'resources' => $directories['app'] . '/resources/',
55
+            'config'    => $directories['app'].'/config/',
56
+            'resources' => $directories['app'].'/resources/',
57 57
         ], $directories);
58 58
     }
59 59
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,11 +43,13 @@
 block discarded – undo
43 43
      */
44 44
     protected function mapDirectories(array $directories): array
45 45
     {
46
-        if (!isset($directories['root'])) {
46
+        if (!isset($directories['root']))
47
+        {
47 48
             throw new BootException('Missing required directory `root`.');
48 49
         }
49 50
 
50
-        if (!isset($directories['app'])) {
51
+        if (!isset($directories['app']))
52
+        {
51 53
             $directories['app'] = $directories['root'] . '/app/';
52 54
         }
53 55
 
Please login to merge, or discard this patch.
src/Boot/tests/FunctionsTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     {
26 26
         $core = TestCore::init([
27 27
             'root'   => __DIR__,
28
-            'config' => __DIR__ . '/config',
28
+            'config' => __DIR__.'/config',
29 29
         ]);
30 30
 
31 31
         /** @var ContainerInterface $c */
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $core = TestCore::init([
42 42
             'root'   => __DIR__,
43
-            'config' => __DIR__ . '/config',
43
+            'config' => __DIR__.'/config',
44 44
         ], new Environment([
45 45
             'key' => '(true)',
46 46
         ]));
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $core = TestCore::init([
59 59
             'root'   => __DIR__,
60
-            'config' => __DIR__ . '/config',
60
+            'config' => __DIR__.'/config',
61 61
         ]);
62 62
 
63 63
         /** @var ContainerInterface $c */
64 64
         $c = $core->getContainer();
65 65
 
66 66
         ContainerScope::runScope($c, function (): void {
67
-            $this->assertDir(__DIR__ . '/config', directory('config'));
67
+            $this->assertDir(__DIR__.'/config', directory('config'));
68 68
         });
69 69
     }
70 70
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
         $core = TestCore::init([
83 83
             'root'   => __DIR__,
84
-            'config' => __DIR__ . '/config',
84
+            'config' => __DIR__.'/config',
85 85
         ]);
86 86
 
87 87
         /** @var ContainerInterface $c */
@@ -109,6 +109,6 @@  discard block
 block discarded – undo
109 109
     private function assertDir($path, $value): void
110 110
     {
111 111
         $path = str_replace(['\\', '//'], '/', $path);
112
-        $this->assertSame(rtrim($path, '/') . '/', $value);
112
+        $this->assertSame(rtrim($path, '/').'/', $value);
113 113
     }
114 114
 }
Please login to merge, or discard this patch.
src/Boot/tests/DirectoriesTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
 
33 33
         $this->assertDir(__DIR__, $dirs->get('root'));
34 34
 
35
-        $this->assertDir(__DIR__ . '/app', $dirs->get('app'));
35
+        $this->assertDir(__DIR__.'/app', $dirs->get('app'));
36 36
 
37
-        $this->assertDir(__DIR__ . '/public', $dirs->get('public'));
37
+        $this->assertDir(__DIR__.'/public', $dirs->get('public'));
38 38
 
39
-        $this->assertDir(__DIR__ . '/app/config', $dirs->get('config'));
40
-        $this->assertDir(__DIR__ . '/app/resources', $dirs->get('resources'));
39
+        $this->assertDir(__DIR__.'/app/config', $dirs->get('config'));
40
+        $this->assertDir(__DIR__.'/app/resources', $dirs->get('resources'));
41 41
 
42
-        $this->assertDir(__DIR__ . '/runtime', $dirs->get('runtime'));
43
-        $this->assertDir(__DIR__ . '/runtime/cache', $dirs->get('cache'));
42
+        $this->assertDir(__DIR__.'/runtime', $dirs->get('runtime'));
43
+        $this->assertDir(__DIR__.'/runtime/cache', $dirs->get('cache'));
44 44
     }
45 45
 
46 46
     public function testKernelException(): void
@@ -101,6 +101,6 @@  discard block
 block discarded – undo
101 101
     private function assertDir($path, $value): void
102 102
     {
103 103
         $path = str_replace(['\\', '//'], '/', $path);
104
-        $this->assertSame(rtrim($path, '/') . '/', $value);
104
+        $this->assertSame(rtrim($path, '/').'/', $value);
105 105
     }
106 106
 }
Please login to merge, or discard this patch.
src/Boot/src/Environment.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function getID(): string
44 44
     {
45
-        if (empty($this->id)) {
45
+        if (empty($this->id)){
46 46
             $this->id = md5(serialize($this->values));
47 47
         }
48 48
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function get(string $name, $default = null)
67 67
     {
68
-        if (isset($this->values[$name])) {
68
+        if (isset($this->values[$name])){
69 69
             return $this->normalize($this->values[$name]);
70 70
         }
71 71
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     {
82 82
         $result = [];
83 83
 
84
-        foreach ($this->values as $key => $value) {
84
+        foreach ($this->values as $key => $value){
85 85
             $result[$key] = $this->normalize($value);
86 86
         }
87 87
 
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
      */
95 95
     protected function normalize($value)
96 96
     {
97
-        if (!is_string($value)) {
97
+        if (!is_string($value)){
98 98
             return $value;
99 99
         }
100 100
 
101 101
         $alias = strtolower($value);
102
-        if (isset(self::VALUE_MAP[$alias])) {
102
+        if (isset(self::VALUE_MAP[$alias])){
103 103
             return self::VALUE_MAP[$alias];
104 104
         }
105 105
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function getID(): string
44 44
     {
45
-        if (empty($this->id)) {
45
+        if (empty($this->id))
46
+        {
46 47
             $this->id = md5(serialize($this->values));
47 48
         }
48 49
 
@@ -65,7 +66,8 @@  discard block
 block discarded – undo
65 66
      */
66 67
     public function get(string $name, $default = null)
67 68
     {
68
-        if (isset($this->values[$name])) {
69
+        if (isset($this->values[$name]))
70
+        {
69 71
             return $this->normalize($this->values[$name]);
70 72
         }
71 73
 
@@ -81,7 +83,8 @@  discard block
 block discarded – undo
81 83
     {
82 84
         $result = [];
83 85
 
84
-        foreach ($this->values as $key => $value) {
86
+        foreach ($this->values as $key => $value)
87
+        {
85 88
             $result[$key] = $this->normalize($value);
86 89
         }
87 90
 
@@ -94,12 +97,14 @@  discard block
 block discarded – undo
94 97
      */
95 98
     protected function normalize($value)
96 99
     {
97
-        if (!is_string($value)) {
100
+        if (!is_string($value))
101
+        {
98 102
             return $value;
99 103
         }
100 104
 
101 105
         $alias = strtolower($value);
102
-        if (isset(self::VALUE_MAP[$alias])) {
106
+        if (isset(self::VALUE_MAP[$alias]))
107
+        {
103 108
             return self::VALUE_MAP[$alias];
104 109
         }
105 110
 
Please login to merge, or discard this patch.
src/Boot/src/Finalizer.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
     public function finalize(bool $terminate = false): void
31 31
     {
32
-        foreach ($this->finalizers as $finalizer) {
32
+        foreach ($this->finalizers as $finalizer){
33 33
             call_user_func($finalizer, $terminate);
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
     public function finalize(bool $terminate = false): void
31 31
     {
32
-        foreach ($this->finalizers as $finalizer) {
32
+        foreach ($this->finalizers as $finalizer)
33
+        {
33 34
             call_user_func($finalizer, $terminate);
34 35
         }
35 36
     }
Please login to merge, or discard this patch.
src/Boot/src/Memory.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $filename = $this->getFilename($section);
46 46
 
47
-        if (!file_exists($filename)) {
47
+        if (!file_exists($filename)){
48 48
             return null;
49 49
         }
50 50
 
51
-        try {
51
+        try{
52 52
             return include($filename);
53
-        } catch (\Throwable $e) {
53
+        }catch (\Throwable $e){
54 54
             return null;
55 55
         }
56 56
     }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $this->files->write(
64 64
             $this->getFilename($section),
65
-            '<?php return ' . var_export($data, true) . ';',
65
+            '<?php return '.var_export($data, true).';',
66 66
             FilesInterface::RUNTIME,
67 67
             true
68 68
         );
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,13 +44,17 @@
 block discarded – undo
44 44
     {
45 45
         $filename = $this->getFilename($section);
46 46
 
47
-        if (!file_exists($filename)) {
47
+        if (!file_exists($filename))
48
+        {
48 49
             return null;
49 50
         }
50 51
 
51
-        try {
52
+        try
53
+        {
52 54
             return include($filename);
53
-        } catch (\Throwable $e) {
55
+        }
56
+        catch (\Throwable $e)
57
+        {
54 58
             return null;
55 59
         }
56 60
     }
Please login to merge, or discard this patch.
src/Boot/src/helpers.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
 use Spiral\Core\ContainerScope;
17 17
 use Spiral\Core\Exception\ScopeException;
18 18
 
19
-if (!function_exists('spiral')) {
19
+if (!function_exists('spiral')){
20 20
     /**
21 21
      * Resolve given alias in current IoC scope.
22 22
      *
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
      */
28 28
     function spiral(string $alias)
29 29
     {
30
-        if (ContainerScope::getContainer() === null) {
30
+        if (ContainerScope::getContainer() === null){
31 31
             throw new ScopeException('Container scope was not set.');
32 32
         }
33 33
 
34
-        try {
34
+        try{
35 35
             return ContainerScope::getContainer()->get($alias);
36
-        } catch (ContainerExceptionInterface $e) {
36
+        }catch (ContainerExceptionInterface $e){
37 37
             throw new ScopeException($e->getMessage(), $e->getCode(), $e);
38 38
         }
39 39
     }
40 40
 }
41 41
 
42
-if (!function_exists('directory')) {
42
+if (!function_exists('directory')){
43 43
     /**
44 44
      * Get directory alias value. Uses application core from the current global scope.
45 45
      *
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     }
56 56
 }
57 57
 
58
-if (!function_exists('env')) {
58
+if (!function_exists('env')){
59 59
     /**
60 60
      * Gets the value of an environment variable. Uses application core from the current global scope.
61 61
      *
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
 use Spiral\Core\ContainerScope;
17 17
 use Spiral\Core\Exception\ScopeException;
18 18
 
19
-if (!function_exists('spiral')) {
19
+if (!function_exists('spiral'))
20
+{
20 21
     /**
21 22
      * Resolve given alias in current IoC scope.
22 23
      *
@@ -27,19 +28,24 @@  discard block
 block discarded – undo
27 28
      */
28 29
     function spiral(string $alias)
29 30
     {
30
-        if (ContainerScope::getContainer() === null) {
31
+        if (ContainerScope::getContainer() === null)
32
+        {
31 33
             throw new ScopeException('Container scope was not set.');
32 34
         }
33 35
 
34
-        try {
36
+        try
37
+        {
35 38
             return ContainerScope::getContainer()->get($alias);
36
-        } catch (ContainerExceptionInterface $e) {
39
+        }
40
+        catch (ContainerExceptionInterface $e)
41
+        {
37 42
             throw new ScopeException($e->getMessage(), $e->getCode(), $e);
38 43
         }
39 44
     }
40 45
 }
41 46
 
42
-if (!function_exists('directory')) {
47
+if (!function_exists('directory'))
48
+{
43 49
     /**
44 50
      * Get directory alias value. Uses application core from the current global scope.
45 51
      *
@@ -55,7 +61,8 @@  discard block
 block discarded – undo
55 61
     }
56 62
 }
57 63
 
58
-if (!function_exists('env')) {
64
+if (!function_exists('env'))
65
+{
59 66
     /**
60 67
      * Gets the value of an environment variable. Uses application core from the current global scope.
61 68
      *
Please login to merge, or discard this patch.