@@ -33,12 +33,12 @@ |
||
33 | 33 | */ |
34 | 34 | public function handle(string $name, string $id, array $payload): void |
35 | 35 | { |
36 | - try { |
|
36 | + try{ |
|
37 | 37 | $this->invoker->invoke( |
38 | 38 | [$this, $this->getHandlerMethod()], |
39 | 39 | \array_merge(['payload' => $payload, 'id' => $id], $payload) |
40 | 40 | ); |
41 | - } catch (Throwable $e) { |
|
41 | + }catch (Throwable $e){ |
|
42 | 42 | $message = \sprintf('[%s] %s', \get_class($this), $e->getMessage()); |
43 | 43 | throw new JobException($message, (int)$e->getCode(), $e); |
44 | 44 | } |
@@ -33,12 +33,15 @@ |
||
33 | 33 | */ |
34 | 34 | public function handle(string $name, string $id, array $payload): void |
35 | 35 | { |
36 | - try { |
|
36 | + try |
|
37 | + { |
|
37 | 38 | $this->invoker->invoke( |
38 | 39 | [$this, $this->getHandlerMethod()], |
39 | 40 | \array_merge(['payload' => $payload, 'id' => $id], $payload) |
40 | 41 | ); |
41 | - } catch (Throwable $e) { |
|
42 | + } |
|
43 | + catch (Throwable $e) |
|
44 | + { |
|
42 | 45 | $message = \sprintf('[%s] %s', \get_class($this), $e->getMessage()); |
43 | 46 | throw new JobException($message, (int)$e->getCode(), $e); |
44 | 47 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public function __construct( |
26 | 26 | HandlerRegistryInterface $registry, |
27 | 27 | FailedJobHandlerInterface $failedJobHandler |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | $this->registry = $registry; |
30 | 30 | $this->failedJobHandler = $failedJobHandler; |
31 | 31 | } |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | /** @inheritdoc */ |
34 | 34 | public function push(string $name, array $payload = [], OptionsInterface $options = null): string |
35 | 35 | { |
36 | - if ($options !== null && $options->getDelay()) { |
|
36 | + if ($options !== null && $options->getDelay()){ |
|
37 | 37 | sleep($options->getDelay()); |
38 | 38 | } |
39 | 39 | |
40 | 40 | $id = (string)Uuid::uuid4(); |
41 | 41 | |
42 | - try { |
|
42 | + try{ |
|
43 | 43 | $this->registry->getHandler($name)->handle($name, $id, $payload); |
44 | - } catch (Throwable $e) { |
|
44 | + }catch (Throwable $e){ |
|
45 | 45 | $this->failedJobHandler->handle( |
46 | 46 | 'sync', |
47 | 47 | 'default', |
@@ -33,15 +33,19 @@ |
||
33 | 33 | /** @inheritdoc */ |
34 | 34 | public function push(string $name, array $payload = [], OptionsInterface $options = null): string |
35 | 35 | { |
36 | - if ($options !== null && $options->getDelay()) { |
|
36 | + if ($options !== null && $options->getDelay()) |
|
37 | + { |
|
37 | 38 | sleep($options->getDelay()); |
38 | 39 | } |
39 | 40 | |
40 | 41 | $id = (string)Uuid::uuid4(); |
41 | 42 | |
42 | - try { |
|
43 | + try |
|
44 | + { |
|
43 | 45 | $this->registry->getHandler($name)->handle($name, $id, $payload); |
44 | - } catch (Throwable $e) { |
|
46 | + } |
|
47 | + catch (Throwable $e) |
|
48 | + { |
|
45 | 49 | $this->failedJobHandler->handle( |
46 | 50 | 'sync', |
47 | 51 | 'default', |
@@ -27,21 +27,21 @@ discard block |
||
27 | 27 | |
28 | 28 | public function createInjection(ReflectionClass $class, string $context = null): QueueInterface |
29 | 29 | { |
30 | - try { |
|
31 | - if ($context === null) { |
|
30 | + try{ |
|
31 | + if ($context === null){ |
|
32 | 32 | $connection = $this->queueManager->getConnection(); |
33 | - } else { |
|
33 | + }else{ |
|
34 | 34 | // Get Queue by context |
35 | - try { |
|
35 | + try{ |
|
36 | 36 | $connection = $this->queueManager->getConnection($context); |
37 | - } catch (InvalidArgumentException $e) { |
|
37 | + }catch (InvalidArgumentException $e){ |
|
38 | 38 | // Case when context doesn't match to configured connections |
39 | 39 | return $this->queueManager->getConnection(); |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | 43 | $this->matchType($class, $context, $connection); |
44 | - } catch (Throwable $e) { |
|
44 | + }catch (Throwable $e){ |
|
45 | 45 | throw new ContainerException(sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
46 | 46 | } |
47 | 47 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | private function matchType(ReflectionClass $class, ?string $context, QueueInterface $connection): void |
57 | 57 | { |
58 | 58 | $className = $class->getName(); |
59 | - if ($className !== QueueInterface::class && !$connection instanceof $className) { |
|
59 | + if ($className !== QueueInterface::class && !$connection instanceof $className){ |
|
60 | 60 | throw new RuntimeException( |
61 | 61 | \sprintf( |
62 | 62 | "The queue obtained by the context `%s` doesn't match the type `%s`.", |
@@ -27,21 +27,30 @@ discard block |
||
27 | 27 | |
28 | 28 | public function createInjection(ReflectionClass $class, string $context = null): QueueInterface |
29 | 29 | { |
30 | - try { |
|
31 | - if ($context === null) { |
|
30 | + try |
|
31 | + { |
|
32 | + if ($context === null) |
|
33 | + { |
|
32 | 34 | $connection = $this->queueManager->getConnection(); |
33 | - } else { |
|
35 | + } |
|
36 | + else |
|
37 | + { |
|
34 | 38 | // Get Queue by context |
35 | - try { |
|
39 | + try |
|
40 | + { |
|
36 | 41 | $connection = $this->queueManager->getConnection($context); |
37 | - } catch (InvalidArgumentException $e) { |
|
42 | + } |
|
43 | + catch (InvalidArgumentException $e) |
|
44 | + { |
|
38 | 45 | // Case when context doesn't match to configured connections |
39 | 46 | return $this->queueManager->getConnection(); |
40 | 47 | } |
41 | 48 | } |
42 | 49 | |
43 | 50 | $this->matchType($class, $context, $connection); |
44 | - } catch (Throwable $e) { |
|
51 | + } |
|
52 | + catch (Throwable $e) |
|
53 | + { |
|
45 | 54 | throw new ContainerException(sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
46 | 55 | } |
47 | 56 | |
@@ -56,7 +65,8 @@ discard block |
||
56 | 65 | private function matchType(ReflectionClass $class, ?string $context, QueueInterface $connection): void |
57 | 66 | { |
58 | 67 | $className = $class->getName(); |
59 | - if ($className !== QueueInterface::class && !$connection instanceof $className) { |
|
68 | + if ($className !== QueueInterface::class && !$connection instanceof $className) |
|
69 | + { |
|
60 | 70 | throw new RuntimeException( |
61 | 71 | \sprintf( |
62 | 72 | "The queue obtained by the context `%s` doesn't match the type `%s`.", |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | { |
42 | 42 | $filename = $this->getFilename($section); |
43 | 43 | |
44 | - if (!file_exists($filename)) { |
|
44 | + if (!file_exists($filename)){ |
|
45 | 45 | return null; |
46 | 46 | } |
47 | 47 | |
48 | - try { |
|
48 | + try{ |
|
49 | 49 | return include($filename); |
50 | - } catch (Throwable $e) { |
|
50 | + }catch (Throwable $e){ |
|
51 | 51 | return null; |
52 | 52 | } |
53 | 53 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $this->files->write( |
61 | 61 | $this->getFilename($section), |
62 | - '<?php return ' . var_export($data, true) . ';', |
|
62 | + '<?php return '.var_export($data, true).';', |
|
63 | 63 | FilesInterface::RUNTIME, |
64 | 64 | true |
65 | 65 | ); |
@@ -41,13 +41,17 @@ |
||
41 | 41 | { |
42 | 42 | $filename = $this->getFilename($section); |
43 | 43 | |
44 | - if (!file_exists($filename)) { |
|
44 | + if (!file_exists($filename)) |
|
45 | + { |
|
45 | 46 | return null; |
46 | 47 | } |
47 | 48 | |
48 | - try { |
|
49 | + try |
|
50 | + { |
|
49 | 51 | return include($filename); |
50 | - } catch (Throwable $e) { |
|
52 | + } |
|
53 | + catch (Throwable $e) |
|
54 | + { |
|
51 | 55 | return null; |
52 | 56 | } |
53 | 57 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public static function handleShutdown(): void |
54 | 54 | { |
55 | - if (!empty($error = error_get_last())) { |
|
55 | + if (!empty($error = error_get_last())){ |
|
56 | 56 | self::handleException( |
57 | 57 | new FatalException( |
58 | 58 | $error['message'], |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public static function handleError($code, $message, $filename = '', $line = 0): void |
79 | 79 | { |
80 | - if (!(error_reporting() & $code)) { |
|
80 | + if (!(error_reporting() & $code)){ |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public static function handleException(Throwable $e): void |
91 | 91 | { |
92 | - if (self::$output === null) { |
|
92 | + if (self::$output === null){ |
|
93 | 93 | self::$output = defined('STDERR') ? STDERR : fopen('php://stderr', 'w+'); |
94 | 94 | } |
95 | 95 | |
96 | - if (php_sapi_name() == 'cli') { |
|
96 | + if (php_sapi_name() == 'cli'){ |
|
97 | 97 | $handler = new ConsoleHandler(self::$output); |
98 | - } else { |
|
98 | + }else{ |
|
99 | 99 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
100 | 100 | } |
101 | 101 |
@@ -52,7 +52,8 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public static function handleShutdown(): void |
54 | 54 | { |
55 | - if (!empty($error = error_get_last())) { |
|
55 | + if (!empty($error = error_get_last())) |
|
56 | + { |
|
56 | 57 | self::handleException( |
57 | 58 | new FatalException( |
58 | 59 | $error['message'], |
@@ -77,7 +78,8 @@ discard block |
||
77 | 78 | */ |
78 | 79 | public static function handleError($code, $message, $filename = '', $line = 0): void |
79 | 80 | { |
80 | - if (!(error_reporting() & $code)) { |
|
81 | + if (!(error_reporting() & $code)) |
|
82 | + { |
|
81 | 83 | return; |
82 | 84 | } |
83 | 85 | |
@@ -89,13 +91,17 @@ discard block |
||
89 | 91 | */ |
90 | 92 | public static function handleException(Throwable $e): void |
91 | 93 | { |
92 | - if (self::$output === null) { |
|
94 | + if (self::$output === null) |
|
95 | + { |
|
93 | 96 | self::$output = defined('STDERR') ? STDERR : fopen('php://stderr', 'w+'); |
94 | 97 | } |
95 | 98 | |
96 | - if (php_sapi_name() == 'cli') { |
|
99 | + if (php_sapi_name() == 'cli') |
|
100 | + { |
|
97 | 101 | $handler = new ConsoleHandler(self::$output); |
98 | - } else { |
|
102 | + } |
|
103 | + else |
|
104 | + { |
|
99 | 105 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
100 | 106 | } |
101 | 107 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | array $directories, |
115 | 115 | bool $handleErrors = true |
116 | 116 | ): self { |
117 | - if ($handleErrors) { |
|
117 | + if ($handleErrors){ |
|
118 | 118 | ExceptionHandler::register(); |
119 | 119 | } |
120 | 120 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $environment ??= new Environment(); |
138 | 138 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
139 | 139 | |
140 | - try { |
|
140 | + try{ |
|
141 | 141 | // will protect any against env overwrite action |
142 | 142 | $this->container->runScope( |
143 | 143 | [EnvironmentInterface::class => $environment], |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $this->bootstrap(); |
147 | 147 | } |
148 | 148 | ); |
149 | - } catch (Throwable $e) { |
|
149 | + }catch (Throwable $e){ |
|
150 | 150 | ExceptionHandler::handleException($e); |
151 | 151 | |
152 | 152 | return null; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function starting(Closure ...$callbacks): void |
168 | 168 | { |
169 | - foreach ($callbacks as $callback) { |
|
169 | + foreach ($callbacks as $callback){ |
|
170 | 170 | $this->startingCallbacks[] = $callback; |
171 | 171 | } |
172 | 172 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function started(Closure ...$callbacks): void |
184 | 184 | { |
185 | - foreach ($callbacks as $callback) { |
|
185 | + foreach ($callbacks as $callback){ |
|
186 | 186 | $this->startedCallbacks[] = $callback; |
187 | 187 | } |
188 | 188 | } |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function serve() |
208 | 208 | { |
209 | - foreach ($this->dispatchers as $dispatcher) { |
|
210 | - if ($dispatcher->canServe()) { |
|
209 | + foreach ($this->dispatchers as $dispatcher){ |
|
210 | + if ($dispatcher->canServe()){ |
|
211 | 211 | return $this->container->runScope( |
212 | 212 | [DispatcherInterface::class => $dispatcher], |
213 | 213 | [$dispatcher, 'serve'] |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | */ |
262 | 262 | private function fireCallbacks(array &$callbacks): void |
263 | 263 | { |
264 | - if ($callbacks === []) { |
|
264 | + if ($callbacks === []){ |
|
265 | 265 | return; |
266 | 266 | } |
267 | 267 | |
268 | - do { |
|
268 | + do{ |
|
269 | 269 | $this->container->invoke(\current($callbacks)); |
270 | - } while (\next($callbacks)); |
|
270 | + }while (\next($callbacks)); |
|
271 | 271 | |
272 | 272 | $callbacks = []; |
273 | 273 | } |
@@ -114,7 +114,8 @@ discard block |
||
114 | 114 | array $directories, |
115 | 115 | bool $handleErrors = true |
116 | 116 | ): self { |
117 | - if ($handleErrors) { |
|
117 | + if ($handleErrors) |
|
118 | + { |
|
118 | 119 | ExceptionHandler::register(); |
119 | 120 | } |
120 | 121 | |
@@ -137,7 +138,8 @@ discard block |
||
137 | 138 | $environment ??= new Environment(); |
138 | 139 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
139 | 140 | |
140 | - try { |
|
141 | + try |
|
142 | + { |
|
141 | 143 | // will protect any against env overwrite action |
142 | 144 | $this->container->runScope( |
143 | 145 | [EnvironmentInterface::class => $environment], |
@@ -146,7 +148,9 @@ discard block |
||
146 | 148 | $this->bootstrap(); |
147 | 149 | } |
148 | 150 | ); |
149 | - } catch (Throwable $e) { |
|
151 | + } |
|
152 | + catch (Throwable $e) |
|
153 | + { |
|
150 | 154 | ExceptionHandler::handleException($e); |
151 | 155 | |
152 | 156 | return null; |
@@ -166,7 +170,8 @@ discard block |
||
166 | 170 | */ |
167 | 171 | public function starting(Closure ...$callbacks): void |
168 | 172 | { |
169 | - foreach ($callbacks as $callback) { |
|
173 | + foreach ($callbacks as $callback) |
|
174 | + { |
|
170 | 175 | $this->startingCallbacks[] = $callback; |
171 | 176 | } |
172 | 177 | } |
@@ -182,7 +187,8 @@ discard block |
||
182 | 187 | */ |
183 | 188 | public function started(Closure ...$callbacks): void |
184 | 189 | { |
185 | - foreach ($callbacks as $callback) { |
|
190 | + foreach ($callbacks as $callback) |
|
191 | + { |
|
186 | 192 | $this->startedCallbacks[] = $callback; |
187 | 193 | } |
188 | 194 | } |
@@ -206,8 +212,10 @@ discard block |
||
206 | 212 | */ |
207 | 213 | public function serve() |
208 | 214 | { |
209 | - foreach ($this->dispatchers as $dispatcher) { |
|
210 | - if ($dispatcher->canServe()) { |
|
215 | + foreach ($this->dispatchers as $dispatcher) |
|
216 | + { |
|
217 | + if ($dispatcher->canServe()) |
|
218 | + { |
|
211 | 219 | return $this->container->runScope( |
212 | 220 | [DispatcherInterface::class => $dispatcher], |
213 | 221 | [$dispatcher, 'serve'] |
@@ -261,11 +269,13 @@ discard block |
||
261 | 269 | */ |
262 | 270 | private function fireCallbacks(array &$callbacks): void |
263 | 271 | { |
264 | - if ($callbacks === []) { |
|
272 | + if ($callbacks === []) |
|
273 | + { |
|
265 | 274 | return; |
266 | 275 | } |
267 | 276 | |
268 | - do { |
|
277 | + do |
|
278 | + { |
|
269 | 279 | $this->container->invoke(\current($callbacks)); |
270 | 280 | } while (\next($callbacks)); |
271 | 281 |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $this->fireCallbacks($startingCallbacks); |
88 | 88 | |
89 | - foreach ($bootloaders as $data) { |
|
89 | + foreach ($bootloaders as $data){ |
|
90 | 90 | $bootloader = $data['bootloader']; |
91 | 91 | $options = $data['options']; |
92 | 92 | $this->invokeBootloader($bootloader, 'start', $options); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function initBootloader(BootloaderInterface $bootloader): iterable |
102 | 102 | { |
103 | - if ($bootloader instanceof DependedInterface) { |
|
103 | + if ($bootloader instanceof DependedInterface){ |
|
104 | 104 | yield from $this->initBootloaders($bootloader->defineDependencies()); |
105 | 105 | } |
106 | 106 | |
@@ -117,30 +117,30 @@ discard block |
||
117 | 117 | */ |
118 | 118 | private function initBootloaders(array $classes): Generator |
119 | 119 | { |
120 | - foreach ($classes as $class => $options) { |
|
120 | + foreach ($classes as $class => $options){ |
|
121 | 121 | // default bootload syntax as simple array |
122 | - if (\is_string($options)) { |
|
122 | + if (\is_string($options)){ |
|
123 | 123 | $class = $options; |
124 | 124 | $options = []; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Replace class aliases with source classes |
128 | - try { |
|
128 | + try{ |
|
129 | 129 | $class = (new ReflectionClass($class))->getName(); |
130 | - } catch (ReflectionException $e) { |
|
130 | + }catch (ReflectionException $e){ |
|
131 | 131 | throw new ClassNotFoundException( |
132 | 132 | \sprintf('Bootloader class `%s` is not exist.', $class) |
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | - if (\in_array($class, $this->classes, true)) { |
|
136 | + if (\in_array($class, $this->classes, true)){ |
|
137 | 137 | continue; |
138 | 138 | } |
139 | 139 | |
140 | 140 | $this->classes[] = $class; |
141 | 141 | $bootloader = $this->container->get($class); |
142 | 142 | |
143 | - if (!$bootloader instanceof BootloaderInterface) { |
|
143 | + if (!$bootloader instanceof BootloaderInterface){ |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function initBindings(array $bindings, array $singletons): void |
158 | 158 | { |
159 | - foreach ($bindings as $aliases => $resolver) { |
|
159 | + foreach ($bindings as $aliases => $resolver){ |
|
160 | 160 | $this->container->bind($aliases, $resolver); |
161 | 161 | } |
162 | 162 | |
163 | - foreach ($singletons as $aliases => $resolver) { |
|
163 | + foreach ($singletons as $aliases => $resolver){ |
|
164 | 164 | $this->container->bindSingleton($aliases, $resolver); |
165 | 165 | } |
166 | 166 | } |
@@ -168,14 +168,14 @@ discard block |
||
168 | 168 | private function invokeBootloader(BootloaderInterface $bootloader, string $method, array $options): void |
169 | 169 | { |
170 | 170 | $refl = new ReflectionClass($bootloader); |
171 | - if (!$refl->hasMethod($method)) { |
|
171 | + if (!$refl->hasMethod($method)){ |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | 175 | $boot = new ReflectionMethod($bootloader, $method); |
176 | 176 | |
177 | 177 | $args = $this->container->resolveArguments($boot); |
178 | - if (!isset($args['boot'])) { |
|
178 | + if (!isset($args['boot'])){ |
|
179 | 179 | $args['boot'] = $options; |
180 | 180 | } |
181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | private function fireCallbacks(array $callbacks): void |
189 | 189 | { |
190 | - foreach ($callbacks as $callback) { |
|
190 | + foreach ($callbacks as $callback){ |
|
191 | 191 | $this->container->invoke($callback); |
192 | 192 | } |
193 | 193 | } |
@@ -86,7 +86,8 @@ discard block |
||
86 | 86 | |
87 | 87 | $this->fireCallbacks($startingCallbacks); |
88 | 88 | |
89 | - foreach ($bootloaders as $data) { |
|
89 | + foreach ($bootloaders as $data) |
|
90 | + { |
|
90 | 91 | $bootloader = $data['bootloader']; |
91 | 92 | $options = $data['options']; |
92 | 93 | $this->invokeBootloader($bootloader, 'start', $options); |
@@ -100,7 +101,8 @@ discard block |
||
100 | 101 | */ |
101 | 102 | protected function initBootloader(BootloaderInterface $bootloader): iterable |
102 | 103 | { |
103 | - if ($bootloader instanceof DependedInterface) { |
|
104 | + if ($bootloader instanceof DependedInterface) |
|
105 | + { |
|
104 | 106 | yield from $this->initBootloaders($bootloader->defineDependencies()); |
105 | 107 | } |
106 | 108 | |
@@ -117,30 +119,37 @@ discard block |
||
117 | 119 | */ |
118 | 120 | private function initBootloaders(array $classes): Generator |
119 | 121 | { |
120 | - foreach ($classes as $class => $options) { |
|
122 | + foreach ($classes as $class => $options) |
|
123 | + { |
|
121 | 124 | // default bootload syntax as simple array |
122 | - if (\is_string($options)) { |
|
125 | + if (\is_string($options)) |
|
126 | + { |
|
123 | 127 | $class = $options; |
124 | 128 | $options = []; |
125 | 129 | } |
126 | 130 | |
127 | 131 | // Replace class aliases with source classes |
128 | - try { |
|
132 | + try |
|
133 | + { |
|
129 | 134 | $class = (new ReflectionClass($class))->getName(); |
130 | - } catch (ReflectionException $e) { |
|
135 | + } |
|
136 | + catch (ReflectionException $e) |
|
137 | + { |
|
131 | 138 | throw new ClassNotFoundException( |
132 | 139 | \sprintf('Bootloader class `%s` is not exist.', $class) |
133 | 140 | ); |
134 | 141 | } |
135 | 142 | |
136 | - if (\in_array($class, $this->classes, true)) { |
|
143 | + if (\in_array($class, $this->classes, true)) |
|
144 | + { |
|
137 | 145 | continue; |
138 | 146 | } |
139 | 147 | |
140 | 148 | $this->classes[] = $class; |
141 | 149 | $bootloader = $this->container->get($class); |
142 | 150 | |
143 | - if (!$bootloader instanceof BootloaderInterface) { |
|
151 | + if (!$bootloader instanceof BootloaderInterface) |
|
152 | + { |
|
144 | 153 | continue; |
145 | 154 | } |
146 | 155 | |
@@ -156,11 +165,13 @@ discard block |
||
156 | 165 | */ |
157 | 166 | private function initBindings(array $bindings, array $singletons): void |
158 | 167 | { |
159 | - foreach ($bindings as $aliases => $resolver) { |
|
168 | + foreach ($bindings as $aliases => $resolver) |
|
169 | + { |
|
160 | 170 | $this->container->bind($aliases, $resolver); |
161 | 171 | } |
162 | 172 | |
163 | - foreach ($singletons as $aliases => $resolver) { |
|
173 | + foreach ($singletons as $aliases => $resolver) |
|
174 | + { |
|
164 | 175 | $this->container->bindSingleton($aliases, $resolver); |
165 | 176 | } |
166 | 177 | } |
@@ -168,14 +179,16 @@ discard block |
||
168 | 179 | private function invokeBootloader(BootloaderInterface $bootloader, string $method, array $options): void |
169 | 180 | { |
170 | 181 | $refl = new ReflectionClass($bootloader); |
171 | - if (!$refl->hasMethod($method)) { |
|
182 | + if (!$refl->hasMethod($method)) |
|
183 | + { |
|
172 | 184 | return; |
173 | 185 | } |
174 | 186 | |
175 | 187 | $boot = new ReflectionMethod($bootloader, $method); |
176 | 188 | |
177 | 189 | $args = $this->container->resolveArguments($boot); |
178 | - if (!isset($args['boot'])) { |
|
190 | + if (!isset($args['boot'])) |
|
191 | + { |
|
179 | 192 | $args['boot'] = $options; |
180 | 193 | } |
181 | 194 | |
@@ -187,7 +200,8 @@ discard block |
||
187 | 200 | */ |
188 | 201 | private function fireCallbacks(array $callbacks): void |
189 | 202 | { |
190 | - foreach ($callbacks as $callback) { |
|
203 | + foreach ($callbacks as $callback) |
|
204 | + { |
|
191 | 205 | $this->container->invoke($callback); |
192 | 206 | } |
193 | 207 | } |
@@ -154,11 +154,11 @@ |
||
154 | 154 | */ |
155 | 155 | public function setDelay($delay): self |
156 | 156 | { |
157 | - if ($delay instanceof DateInterval) { |
|
157 | + if ($delay instanceof DateInterval){ |
|
158 | 158 | $delay = (new DateTimeImmutable('NOW'))->add($delay); |
159 | 159 | } |
160 | 160 | |
161 | - if ($delay instanceof DateTimeInterface) { |
|
161 | + if ($delay instanceof DateTimeInterface){ |
|
162 | 162 | $delay = max(0, $delay->getTimestamp() - time()); |
163 | 163 | } |
164 | 164 |
@@ -154,11 +154,13 @@ |
||
154 | 154 | */ |
155 | 155 | public function setDelay($delay): self |
156 | 156 | { |
157 | - if ($delay instanceof DateInterval) { |
|
157 | + if ($delay instanceof DateInterval) |
|
158 | + { |
|
158 | 159 | $delay = (new DateTimeImmutable('NOW'))->add($delay); |
159 | 160 | } |
160 | 161 | |
161 | - if ($delay instanceof DateTimeInterface) { |
|
162 | + if ($delay instanceof DateTimeInterface) |
|
163 | + { |
|
162 | 164 | $delay = max(0, $delay->getTimestamp() - time()); |
163 | 165 | } |
164 | 166 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $name ??= $this->default; |
64 | 64 | |
65 | - if (!isset($this->resolvers[$name])) { |
|
65 | + if (!isset($this->resolvers[$name])){ |
|
66 | 66 | throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
67 | 67 | } |
68 | 68 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function add(string $name, UriResolverInterface $resolver, bool $overwrite = false): void |
76 | 76 | { |
77 | - if ($overwrite === false && isset($this->resolvers[$name])) { |
|
77 | + if ($overwrite === false && isset($this->resolvers[$name])){ |
|
78 | 78 | throw new InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
79 | 79 | } |
80 | 80 |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | { |
63 | 63 | $name ??= $this->default; |
64 | 64 | |
65 | - if (!isset($this->resolvers[$name])) { |
|
65 | + if (!isset($this->resolvers[$name])) |
|
66 | + { |
|
66 | 67 | throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
67 | 68 | } |
68 | 69 | |
@@ -74,7 +75,8 @@ discard block |
||
74 | 75 | */ |
75 | 76 | public function add(string $name, UriResolverInterface $resolver, bool $overwrite = false): void |
76 | 77 | { |
77 | - if ($overwrite === false && isset($this->resolvers[$name])) { |
|
78 | + if ($overwrite === false && isset($this->resolvers[$name])) |
|
79 | + { |
|
78 | 80 | throw new InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
79 | 81 | } |
80 | 82 |