@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | */ |
43 | 43 | protected function getLogger(string $channel = null): LoggerInterface |
44 | 44 | { |
45 | - if ($channel !== null) { |
|
45 | + if ($channel !== null){ |
|
46 | 46 | return $this->allocateLogger($channel); |
47 | 47 | } |
48 | 48 | |
49 | - if ($this->logger !== null) { |
|
49 | + if ($this->logger !== null){ |
|
50 | 50 | return $this->logger; |
51 | 51 | } |
52 | 52 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | private function allocateLogger(string $channel): LoggerInterface |
64 | 64 | { |
65 | 65 | $container = ContainerScope::getContainer(); |
66 | - if (empty($container) || !$container->has(LogsInterface::class)) { |
|
66 | + if (empty($container) || !$container->has(LogsInterface::class)){ |
|
67 | 67 | return $this->logger ?? new NullLogger(); |
68 | 68 | } |
69 | 69 |
@@ -42,11 +42,13 @@ discard block |
||
42 | 42 | */ |
43 | 43 | protected function getLogger(string $channel = null): LoggerInterface |
44 | 44 | { |
45 | - if ($channel !== null) { |
|
45 | + if ($channel !== null) |
|
46 | + { |
|
46 | 47 | return $this->allocateLogger($channel); |
47 | 48 | } |
48 | 49 | |
49 | - if ($this->logger !== null) { |
|
50 | + if ($this->logger !== null) |
|
51 | + { |
|
50 | 52 | return $this->logger; |
51 | 53 | } |
52 | 54 | |
@@ -63,7 +65,8 @@ discard block |
||
63 | 65 | private function allocateLogger(string $channel): LoggerInterface |
64 | 66 | { |
65 | 67 | $container = ContainerScope::getContainer(); |
66 | - if (empty($container) || !$container->has(LogsInterface::class)) { |
|
68 | + if (empty($container) || !$container->has(LogsInterface::class)) |
|
69 | + { |
|
67 | 70 | return $this->logger ?? new NullLogger(); |
68 | 71 | } |
69 | 72 |
@@ -34,8 +34,8 @@ |
||
34 | 34 | public function setTags(array $tags): void |
35 | 35 | { |
36 | 36 | $setTags = []; |
37 | - foreach ($tags as $key => $value) { |
|
38 | - if (!is_string($value)) { |
|
37 | + foreach ($tags as $key => $value){ |
|
38 | + if (!is_string($value)){ |
|
39 | 39 | throw new StateException(sprintf( |
40 | 40 | 'Invalid tag value, string expected got %s', |
41 | 41 | is_object($value) ? get_class($value) : gettype($value) |
@@ -34,8 +34,10 @@ |
||
34 | 34 | public function setTags(array $tags): void |
35 | 35 | { |
36 | 36 | $setTags = []; |
37 | - foreach ($tags as $key => $value) { |
|
38 | - if (!is_string($value)) { |
|
37 | + foreach ($tags as $key => $value) |
|
38 | + { |
|
39 | + if (!is_string($value)) |
|
40 | + { |
|
39 | 41 | throw new StateException(sprintf( |
40 | 42 | 'Invalid tag value, string expected got %s', |
41 | 43 | is_object($value) ? get_class($value) : gettype($value) |
@@ -21,17 +21,17 @@ discard block |
||
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 |
||
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 | } |
@@ -29,25 +29,25 @@ |
||
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 | } |
@@ -43,11 +43,13 @@ |
||
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 |
@@ -35,25 +35,25 @@ |
||
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 | } |
@@ -43,11 +43,13 @@ |
||
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 |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -32,15 +32,15 @@ discard block |
||
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 |
||
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 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | 'root' => __DIR__, |
45 | 45 | ]); |
46 | 46 | |
47 | - $d = new class() implements DispatcherInterface { |
|
47 | + $d = new class() implements DispatcherInterface{ |
|
48 | 48 | public $fired = false; |
49 | 49 | |
50 | 50 | public function canServe(): bool |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | 'root' => __DIR__, |
74 | 74 | ]); |
75 | 75 | |
76 | - $d = new class() implements DispatcherInterface { |
|
76 | + $d = new class() implements DispatcherInterface{ |
|
77 | 77 | public function canServe(): bool |
78 | 78 | { |
79 | 79 | return true; |
@@ -44,7 +44,8 @@ discard block |
||
44 | 44 | 'root' => __DIR__, |
45 | 45 | ]); |
46 | 46 | |
47 | - $d = new class() implements DispatcherInterface { |
|
47 | + $d = new class() implements DispatcherInterface |
|
48 | + { |
|
48 | 49 | public $fired = false; |
49 | 50 | |
50 | 51 | public function canServe(): bool |
@@ -73,7 +74,8 @@ discard block |
||
73 | 74 | 'root' => __DIR__, |
74 | 75 | ]); |
75 | 76 | |
76 | - $d = new class() implements DispatcherInterface { |
|
77 | + $d = new class() implements DispatcherInterface |
|
78 | + { |
|
77 | 79 | public function canServe(): bool |
78 | 80 | { |
79 | 81 | return true; |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function boot(array $classes): void |
79 | 79 | { |
80 | - foreach ($classes as $class => $options) { |
|
80 | + foreach ($classes as $class => $options){ |
|
81 | 81 | // default bootload syntax as simple array |
82 | - if (is_string($options)) { |
|
82 | + if (is_string($options)){ |
|
83 | 83 | $class = $options; |
84 | 84 | $options = []; |
85 | 85 | } |
86 | 86 | |
87 | - if (in_array($class, $this->classes)) { |
|
87 | + if (in_array($class, $this->classes)){ |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | 91 | $this->classes[] = $class; |
92 | 92 | $bootloader = $this->container->get($class); |
93 | 93 | |
94 | - if (!$bootloader instanceof BootloaderInterface) { |
|
94 | + if (!$bootloader instanceof BootloaderInterface){ |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | |
@@ -107,17 +107,17 @@ discard block |
||
107 | 107 | */ |
108 | 108 | protected function initBootloader(BootloaderInterface $bootloader, array $options = []): void |
109 | 109 | { |
110 | - if ($bootloader instanceof DependedInterface) { |
|
110 | + if ($bootloader instanceof DependedInterface){ |
|
111 | 111 | $this->boot($bootloader->defineDependencies()); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $this->initBindings($bootloader->defineBindings(), $bootloader->defineSingletons()); |
115 | 115 | |
116 | - if ((new \ReflectionClass($bootloader))->hasMethod('boot')) { |
|
116 | + if ((new \ReflectionClass($bootloader))->hasMethod('boot')){ |
|
117 | 117 | $boot = new \ReflectionMethod($bootloader, 'boot'); |
118 | 118 | |
119 | 119 | $args = $this->container->resolveArguments($boot, $options); |
120 | - if (!isset($args['boot'])) { |
|
120 | + if (!isset($args['boot'])){ |
|
121 | 121 | $args['boot'] = $options; |
122 | 122 | } |
123 | 123 | |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function initBindings(array $bindings, array $singletons): void |
135 | 135 | { |
136 | - foreach ($bindings as $aliases => $resolver) { |
|
136 | + foreach ($bindings as $aliases => $resolver){ |
|
137 | 137 | $this->container->bind($aliases, $resolver); |
138 | 138 | } |
139 | 139 | |
140 | - foreach ($singletons as $aliases => $resolver) { |
|
140 | + foreach ($singletons as $aliases => $resolver){ |
|
141 | 141 | $this->container->bindSingleton($aliases, $resolver); |
142 | 142 | } |
143 | 143 | } |
@@ -77,21 +77,25 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function boot(array $classes): void |
79 | 79 | { |
80 | - foreach ($classes as $class => $options) { |
|
80 | + foreach ($classes as $class => $options) |
|
81 | + { |
|
81 | 82 | // default bootload syntax as simple array |
82 | - if (is_string($options)) { |
|
83 | + if (is_string($options)) |
|
84 | + { |
|
83 | 85 | $class = $options; |
84 | 86 | $options = []; |
85 | 87 | } |
86 | 88 | |
87 | - if (in_array($class, $this->classes)) { |
|
89 | + if (in_array($class, $this->classes)) |
|
90 | + { |
|
88 | 91 | continue; |
89 | 92 | } |
90 | 93 | |
91 | 94 | $this->classes[] = $class; |
92 | 95 | $bootloader = $this->container->get($class); |
93 | 96 | |
94 | - if (!$bootloader instanceof BootloaderInterface) { |
|
97 | + if (!$bootloader instanceof BootloaderInterface) |
|
98 | + { |
|
95 | 99 | continue; |
96 | 100 | } |
97 | 101 | |
@@ -107,17 +111,20 @@ discard block |
||
107 | 111 | */ |
108 | 112 | protected function initBootloader(BootloaderInterface $bootloader, array $options = []): void |
109 | 113 | { |
110 | - if ($bootloader instanceof DependedInterface) { |
|
114 | + if ($bootloader instanceof DependedInterface) |
|
115 | + { |
|
111 | 116 | $this->boot($bootloader->defineDependencies()); |
112 | 117 | } |
113 | 118 | |
114 | 119 | $this->initBindings($bootloader->defineBindings(), $bootloader->defineSingletons()); |
115 | 120 | |
116 | - if ((new \ReflectionClass($bootloader))->hasMethod('boot')) { |
|
121 | + if ((new \ReflectionClass($bootloader))->hasMethod('boot')) |
|
122 | + { |
|
117 | 123 | $boot = new \ReflectionMethod($bootloader, 'boot'); |
118 | 124 | |
119 | 125 | $args = $this->container->resolveArguments($boot, $options); |
120 | - if (!isset($args['boot'])) { |
|
126 | + if (!isset($args['boot'])) |
|
127 | + { |
|
121 | 128 | $args['boot'] = $options; |
122 | 129 | } |
123 | 130 | |
@@ -133,11 +140,13 @@ discard block |
||
133 | 140 | */ |
134 | 141 | protected function initBindings(array $bindings, array $singletons): void |
135 | 142 | { |
136 | - foreach ($bindings as $aliases => $resolver) { |
|
143 | + foreach ($bindings as $aliases => $resolver) |
|
144 | + { |
|
137 | 145 | $this->container->bind($aliases, $resolver); |
138 | 146 | } |
139 | 147 | |
140 | - foreach ($singletons as $aliases => $resolver) { |
|
148 | + foreach ($singletons as $aliases => $resolver) |
|
149 | + { |
|
141 | 150 | $this->container->bindSingleton($aliases, $resolver); |
142 | 151 | } |
143 | 152 | } |