@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | array $directories, |
| 117 | 117 | bool $handleErrors = true |
| 118 | 118 | ): self {
|
| 119 | - if ($handleErrors) {
|
|
| 119 | + if ($handleErrors){
|
|
| 120 | 120 | ExceptionHandler::register(); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function run(?EnvironmentInterface $environment = null): ?self |
| 138 | 138 | {
|
| 139 | - try {
|
|
| 139 | + try{
|
|
| 140 | 140 | // will protect any against env overwrite action |
| 141 | 141 | $this->container->runScope( |
| 142 | 142 | [EnvironmentInterface::class => $environment ?? new Environment()], |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $this->bootstrap(); |
| 146 | 146 | } |
| 147 | 147 | ); |
| 148 | - } catch (\Throwable $e) {
|
|
| 148 | + }catch (\Throwable $e){
|
|
| 149 | 149 | ExceptionHandler::handleException($e); |
| 150 | 150 | |
| 151 | 151 | return null; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | public function starting(Closure ...$callbacks): void |
| 167 | 167 | {
|
| 168 | - foreach ($callbacks as $callback) {
|
|
| 168 | + foreach ($callbacks as $callback){
|
|
| 169 | 169 | $this->startingCallbacks[] = $callback; |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function started(Closure ...$callbacks): void |
| 183 | 183 | {
|
| 184 | - foreach ($callbacks as $callback) {
|
|
| 184 | + foreach ($callbacks as $callback){
|
|
| 185 | 185 | $this->startedCallbacks[] = $callback; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function serve() |
| 207 | 207 | {
|
| 208 | - foreach ($this->dispatchers as $dispatcher) {
|
|
| 209 | - if ($dispatcher->canServe()) {
|
|
| 208 | + foreach ($this->dispatchers as $dispatcher){
|
|
| 209 | + if ($dispatcher->canServe()){
|
|
| 210 | 210 | return $this->container->runScope( |
| 211 | 211 | [DispatcherInterface::class => $dispatcher], |
| 212 | 212 | [$dispatcher, 'serve'] |
@@ -260,13 +260,13 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | private function fireCallbacks(array &$callbacks): void |
| 262 | 262 | {
|
| 263 | - if ($callbacks === []) {
|
|
| 263 | + if ($callbacks === []){
|
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - do {
|
|
| 267 | + do{
|
|
| 268 | 268 | \current($callbacks)($this); |
| 269 | - } while (\next($callbacks)); |
|
| 269 | + }while (\next($callbacks)); |
|
| 270 | 270 | |
| 271 | 271 | $callbacks = []; |
| 272 | 272 | } |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | * Core responsible for application initialization, bootloading of all required services, |
| 21 | 21 | * environment and directory management, exception handling. |
| 22 | 22 | */ |
| 23 | -abstract class AbstractKernel implements KernelInterface |
|
| 24 | -{
|
|
| 23 | +abstract class AbstractKernel implements KernelInterface |
|
| 24 | +{ |
|
| 25 | 25 | /** Defines list of bootloaders to be used for core initialisation and all system components. */ |
| 26 | 26 | protected const SYSTEM = [CoreBootloader::class]; |
| 27 | 27 | |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @throws \Throwable |
| 54 | 54 | */ |
| 55 | - public function __construct(Container $container, array $directories) |
|
| 56 | - {
|
|
| 55 | + public function __construct(Container $container, array $directories) |
|
| 56 | + { |
|
| 57 | 57 | $this->container = $container; |
| 58 | 58 | |
| 59 | 59 | $this->container->bindSingleton(KernelInterface::class, $this); |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * Terminate the application. |
| 77 | 77 | */ |
| 78 | - public function __destruct() |
|
| 79 | - {
|
|
| 78 | + public function __destruct() |
|
| 79 | + { |
|
| 80 | 80 | $this->finalizer->finalize(true); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -116,7 +116,8 @@ discard block |
||
| 116 | 116 | array $directories, |
| 117 | 117 | bool $handleErrors = true |
| 118 | 118 | ): self {
|
| 119 | - if ($handleErrors) {
|
|
| 119 | + if ($handleErrors) |
|
| 120 | + { |
|
| 120 | 121 | ExceptionHandler::register(); |
| 121 | 122 | } |
| 122 | 123 | |
@@ -136,7 +137,8 @@ discard block |
||
| 136 | 137 | */ |
| 137 | 138 | public function run(?EnvironmentInterface $environment = null): ?self |
| 138 | 139 | {
|
| 139 | - try {
|
|
| 140 | + try |
|
| 141 | + { |
|
| 140 | 142 | // will protect any against env overwrite action |
| 141 | 143 | $this->container->runScope( |
| 142 | 144 | [EnvironmentInterface::class => $environment ?? new Environment()], |
@@ -145,7 +147,9 @@ discard block |
||
| 145 | 147 | $this->bootstrap(); |
| 146 | 148 | } |
| 147 | 149 | ); |
| 148 | - } catch (\Throwable $e) {
|
|
| 150 | + } |
|
| 151 | + catch (\Throwable $e) |
|
| 152 | + { |
|
| 149 | 153 | ExceptionHandler::handleException($e); |
| 150 | 154 | |
| 151 | 155 | return null; |
@@ -165,7 +169,8 @@ discard block |
||
| 165 | 169 | */ |
| 166 | 170 | public function starting(Closure ...$callbacks): void |
| 167 | 171 | {
|
| 168 | - foreach ($callbacks as $callback) {
|
|
| 172 | + foreach ($callbacks as $callback) |
|
| 173 | + { |
|
| 169 | 174 | $this->startingCallbacks[] = $callback; |
| 170 | 175 | } |
| 171 | 176 | } |
@@ -181,7 +186,8 @@ discard block |
||
| 181 | 186 | */ |
| 182 | 187 | public function started(Closure ...$callbacks): void |
| 183 | 188 | {
|
| 184 | - foreach ($callbacks as $callback) {
|
|
| 189 | + foreach ($callbacks as $callback) |
|
| 190 | + { |
|
| 185 | 191 | $this->startedCallbacks[] = $callback; |
| 186 | 192 | } |
| 187 | 193 | } |
@@ -203,10 +209,12 @@ discard block |
||
| 203 | 209 | * @throws BootException |
| 204 | 210 | * @throws \Throwable |
| 205 | 211 | */ |
| 206 | - public function serve() |
|
| 207 | - {
|
|
| 208 | - foreach ($this->dispatchers as $dispatcher) {
|
|
| 209 | - if ($dispatcher->canServe()) {
|
|
| 212 | + public function serve() |
|
| 213 | + { |
|
| 214 | + foreach ($this->dispatchers as $dispatcher) |
|
| 215 | + { |
|
| 216 | + if ($dispatcher->canServe()) |
|
| 217 | + { |
|
| 210 | 218 | return $this->container->runScope( |
| 211 | 219 | [DispatcherInterface::class => $dispatcher], |
| 212 | 220 | [$dispatcher, 'serve'] |
@@ -260,11 +268,13 @@ discard block |
||
| 260 | 268 | */ |
| 261 | 269 | private function fireCallbacks(array &$callbacks): void |
| 262 | 270 | {
|
| 263 | - if ($callbacks === []) {
|
|
| 271 | + if ($callbacks === []) |
|
| 272 | + { |
|
| 264 | 273 | return; |
| 265 | 274 | } |
| 266 | 275 | |
| 267 | - do {
|
|
| 276 | + do |
|
| 277 | + { |
|
| 268 | 278 | \current($callbacks)($this); |
| 269 | 279 | } while (\next($callbacks)); |
| 270 | 280 | |