@@ -23,8 +23,8 @@ |
||
| 23 | 23 | public function resolveAlias(string $alias): string |
| 24 | 24 | { |
| 25 | 25 | $antiCircleReference = []; |
| 26 | - while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])) { |
|
| 27 | - if (\in_array($alias, $antiCircleReference, true)) { |
|
| 26 | + while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])){ |
|
| 27 | + if (\in_array($alias, $antiCircleReference, true)){ |
|
| 28 | 28 | throw new ContainerException("Circle reference detected for alias `$alias`."); |
| 29 | 29 | } |
| 30 | 30 | $antiCircleReference[] = $alias; |
@@ -81,12 +81,12 @@ |
||
| 81 | 81 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 82 | 82 | }); |
| 83 | 83 | |
| 84 | - if (!class_exists('Spiral\RoadRunnerBridge\Http\Dispatcher')) { |
|
| 85 | - if (class_exists(PSR7Client::class)) { |
|
| 84 | + if (!class_exists('Spiral\RoadRunnerBridge\Http\Dispatcher')){ |
|
| 85 | + if (class_exists(PSR7Client::class)){ |
|
| 86 | 86 | $kernel->addDispatcher($factory->make(LegacyRrDispatcher::class)); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if (class_exists(PSR7Worker::class)) { |
|
| 89 | + if (class_exists(PSR7Worker::class)){ |
|
| 90 | 90 | $kernel->addDispatcher($factory->make(RrDispatcher::class)); |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $this->fireCallbacks($startingCallbacks); |
| 82 | 82 | |
| 83 | - foreach ($bootloaders as $data) { |
|
| 83 | + foreach ($bootloaders as $data){ |
|
| 84 | 84 | $bootloader = $data['bootloader']; |
| 85 | 85 | $options = $data['options']; |
| 86 | 86 | $this->invokeBootloader($bootloader, 'start', $options); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | protected function initBootloader(BootloaderInterface $bootloader): iterable |
| 96 | 96 | { |
| 97 | - if ($bootloader instanceof DependedInterface) { |
|
| 97 | + if ($bootloader instanceof DependedInterface){ |
|
| 98 | 98 | yield from $this->initBootloaders($bootloader->defineDependencies()); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -111,30 +111,30 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | private function initBootloaders(array $classes): \Generator |
| 113 | 113 | { |
| 114 | - foreach ($classes as $class => $options) { |
|
| 114 | + foreach ($classes as $class => $options){ |
|
| 115 | 115 | // default bootload syntax as simple array |
| 116 | - if (\is_string($options)) { |
|
| 116 | + if (\is_string($options)){ |
|
| 117 | 117 | $class = $options; |
| 118 | 118 | $options = []; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // Replace class aliases with source classes |
| 122 | - try { |
|
| 122 | + try{ |
|
| 123 | 123 | $class = (new \ReflectionClass($class))->getName(); |
| 124 | - } catch (\ReflectionException $e) { |
|
| 124 | + }catch (\ReflectionException $e){ |
|
| 125 | 125 | throw new ClassNotFoundException( |
| 126 | 126 | \sprintf('Bootloader class `%s` is not exist.', $class) |
| 127 | 127 | ); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if (\in_array($class, $this->classes, true)) { |
|
| 130 | + if (\in_array($class, $this->classes, true)){ |
|
| 131 | 131 | continue; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $this->classes[] = $class; |
| 135 | 135 | $bootloader = $this->container->get($class); |
| 136 | 136 | |
| 137 | - if (!$bootloader instanceof BootloaderInterface) { |
|
| 137 | + if (!$bootloader instanceof BootloaderInterface){ |
|
| 138 | 138 | continue; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | private function initBindings(array $bindings, array $singletons): void |
| 152 | 152 | { |
| 153 | - foreach ($bindings as $aliases => $resolver) { |
|
| 153 | + foreach ($bindings as $aliases => $resolver){ |
|
| 154 | 154 | $this->container->bind($aliases, $resolver); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - foreach ($singletons as $aliases => $resolver) { |
|
| 157 | + foreach ($singletons as $aliases => $resolver){ |
|
| 158 | 158 | $this->container->bindSingleton($aliases, $resolver); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | private function invokeBootloader(BootloaderInterface $bootloader, string $method, array $options): void |
| 163 | 163 | { |
| 164 | 164 | $refl = new \ReflectionClass($bootloader); |
| 165 | - if (!$refl->hasMethod($method)) { |
|
| 165 | + if (!$refl->hasMethod($method)){ |
|
| 166 | 166 | return; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $boot = new \ReflectionMethod($bootloader, $method); |
| 170 | 170 | |
| 171 | 171 | $args = $this->container->resolveArguments($boot); |
| 172 | - if (!isset($args['boot'])) { |
|
| 172 | + if (!isset($args['boot'])){ |
|
| 173 | 173 | $args['boot'] = $options; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | private function fireCallbacks(array $callbacks): void |
| 183 | 183 | { |
| 184 | - foreach ($callbacks as $callback) { |
|
| 184 | + foreach ($callbacks as $callback){ |
|
| 185 | 185 | $this->container->invoke($callback); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -48,18 +48,18 @@ discard block |
||
| 48 | 48 | public function boot(Container $container, FinalizerInterface $finalizer): void |
| 49 | 49 | { |
| 50 | 50 | $finalizer->addFinalizer(static function () use ($container): void { |
| 51 | - if ($container->hasInstance(LoggerInterface::class)) { |
|
| 51 | + if ($container->hasInstance(LoggerInterface::class)){ |
|
| 52 | 52 | $logger = $container->get(LoggerInterface::class); |
| 53 | 53 | |
| 54 | - if ($logger instanceof ResettableInterface) { |
|
| 54 | + if ($logger instanceof ResettableInterface){ |
|
| 55 | 55 | $logger->reset(); |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if ($container->hasInstance(LogsInterface::class)) { |
|
| 59 | + if ($container->hasInstance(LogsInterface::class)){ |
|
| 60 | 60 | $factory = $container->get(LogsInterface::class); |
| 61 | 61 | |
| 62 | - if ($factory instanceof ResettableInterface) { |
|
| 62 | + if ($factory instanceof ResettableInterface){ |
|
| 63 | 63 | $factory->reset(); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $name = MonologConfig::CONFIG; |
| 79 | 79 | |
| 80 | - if (!isset($this->config->getConfig($name)['handlers'][$channel])) { |
|
| 80 | + if (!isset($this->config->getConfig($name)['handlers'][$channel])){ |
|
| 81 | 81 | $this->config->modify($name, new Append('handlers', $channel, [])); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $this->config->modify( |
| 85 | 85 | $name, |
| 86 | 86 | new Append( |
| 87 | - 'handlers.' . $channel, |
|
| 87 | + 'handlers.'.$channel, |
|
| 88 | 88 | null, |
| 89 | 89 | $handler |
| 90 | 90 | ) |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | MonologConfig $config, |
| 52 | 52 | ListenerRegistryInterface $listenerRegistry, |
| 53 | 53 | FactoryInterface $factory |
| 54 | - ) { |
|
| 54 | + ){ |
|
| 55 | 55 | $this->config = $config; |
| 56 | 56 | $this->factory = $factory; |
| 57 | 57 | $this->eventHandler = new EventHandler($listenerRegistry, $config->getEventLevel()); |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getLogger(string $channel = null): LoggerInterface |
| 64 | 64 | { |
| 65 | - if ($channel === null || $channel == self::DEFAULT) { |
|
| 66 | - if ($this->default !== null) { |
|
| 65 | + if ($channel === null || $channel == self::DEFAULT){ |
|
| 66 | + if ($this->default !== null){ |
|
| 67 | 67 | // we should use only one default logger per system |
| 68 | 68 | return $this->default; |
| 69 | 69 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | public function reset() |
| 95 | 95 | { |
| 96 | - if ($this->default instanceof ResettableInterface) { |
|
| 96 | + if ($this->default instanceof ResettableInterface){ |
|
| 97 | 97 | $this->default->reset(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -111,15 +111,15 @@ discard block |
||
| 111 | 111 | // always include default handler |
| 112 | 112 | $handlers = []; |
| 113 | 113 | |
| 114 | - foreach ($this->config->getHandlers($channel) as $handler) { |
|
| 115 | - if (!$handler instanceof Autowire) { |
|
| 114 | + foreach ($this->config->getHandlers($channel) as $handler){ |
|
| 115 | + if (!$handler instanceof Autowire){ |
|
| 116 | 116 | $handlers[] = $handler; |
| 117 | 117 | continue; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - try { |
|
| 120 | + try{ |
|
| 121 | 121 | $handlers[] = $handler->resolve($this->factory); |
| 122 | - } catch (ContainerExceptionInterface $e) { |
|
| 122 | + }catch (ContainerExceptionInterface $e){ |
|
| 123 | 123 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -138,20 +138,20 @@ discard block |
||
| 138 | 138 | protected function getProcessors(string $channel): array |
| 139 | 139 | { |
| 140 | 140 | $processors = []; |
| 141 | - foreach ($this->config->getProcessors($channel) as $processor) { |
|
| 142 | - if (!$processor instanceof Autowire) { |
|
| 141 | + foreach ($this->config->getProcessors($channel) as $processor){ |
|
| 142 | + if (!$processor instanceof Autowire){ |
|
| 143 | 143 | $processors[] = $processor; |
| 144 | 144 | continue; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - try { |
|
| 147 | + try{ |
|
| 148 | 148 | $processors[] = $processor->resolve($this->factory); |
| 149 | - } catch (ContainerExceptionInterface $e) { |
|
| 149 | + }catch (ContainerExceptionInterface $e){ |
|
| 150 | 150 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if ($processors === []) { |
|
| 154 | + if ($processors === []){ |
|
| 155 | 155 | $processors[] = new PsrLogMessageProcessor(); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -20,11 +20,11 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function handle(string $name, string $id, array $payload): void |
| 22 | 22 | { |
| 23 | - if (!isset($payload['object'])) { |
|
| 23 | + if (!isset($payload['object'])){ |
|
| 24 | 24 | throw new InvalidArgumentException('Payload `object` key is required.'); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if (!is_object($payload['object'])) { |
|
| 27 | + if (!is_object($payload['object'])){ |
|
| 28 | 28 | throw new InvalidArgumentException('Payload `object` key value type should be an object.'); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -20,11 +20,11 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function handle(string $name, string $id, array $payload): void |
| 22 | 22 | { |
| 23 | - if (!isset($payload['callback'])) { |
|
| 23 | + if (!isset($payload['callback'])){ |
|
| 24 | 24 | throw new InvalidArgumentException('Payload `callback` key is required.'); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if (!$payload['callback'] instanceof \Closure) { |
|
| 27 | + if (!$payload['callback'] instanceof \Closure){ |
|
| 28 | 28 | throw new InvalidArgumentException('Payload `callback` key value type should be a closure.'); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function handle(string $name, string $id, $payload): void |
| 50 | 50 | { |
| 51 | - if (\is_string($payload)) { |
|
| 51 | + if (\is_string($payload)){ |
|
| 52 | 52 | $payload = json_decode($payload, true); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (!\is_array($payload)) { |
|
| 55 | + if (!\is_array($payload)){ |
|
| 56 | 56 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -60,15 +60,15 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $email = $this->renderer->render($message); |
| 62 | 62 | |
| 63 | - if ($email->getFrom() === []) { |
|
| 63 | + if ($email->getFrom() === []){ |
|
| 64 | 64 | $email->from(Address::create($this->config->getFromAddress())); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $recipients = $this->getRecipients($email); |
| 68 | 68 | |
| 69 | - try { |
|
| 69 | + try{ |
|
| 70 | 70 | $this->mailer->send($email); |
| 71 | - } catch (TransportExceptionInterface $e) { |
|
| 71 | + }catch (TransportExceptionInterface $e){ |
|
| 72 | 72 | $this->getLogger()->error( |
| 73 | 73 | sprintf( |
| 74 | 74 | 'Failed to send `%s` to "%s": %s', |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
| 100 | 100 | |
| 101 | - foreach ($addresses as $address) { |
|
| 101 | + foreach ($addresses as $address){ |
|
| 102 | 102 | $emails[] = $address->toString(); |
| 103 | 103 | } |
| 104 | 104 | |