GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 890c9c...35b399 )
by
unknown
02:03
created

Router::setPage()   A

Complexity

Conditions 5
Paths 7

Size

Total Lines 28
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 14
nc 7
nop 1
dl 0
loc 28
rs 9.4888
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Framework\Http;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Framework\Containers\Modules\DataStructures\Module as FrameworkModuleDataStructure;
19
use O2System\Kernel\Http\Message\Uri as KernelMessageUri;
20
use O2System\Kernel\Http\Message\Uri\Segments as KernelMessageUriSegments;
21
use O2System\Kernel\Http\Router as KernelRouter;
22
use O2System\Kernel\Http\Router\Addresses as KernelAddresses;
23
use O2System\Kernel\Http\Router\DataStructures\Action as KernelActionDataStructure;
24
use O2System\Kernel\Http\Router\DataStructures\Controller as KernelControllerDataStructure;
25
use O2System\Spl\Info\SplFileInfo;
26
27
/**
28
 * Class Router
29
 *
30
 * @package O2System
31
 */
32
class Router extends KernelRouter
33
{
34
    /**
35
     * Router::parseRequest
36
     *
37
     * @param KernelMessageUri|null $uri
38
     *
39
     * @return bool
40
     * @throws \ReflectionException
41
     */
42
    public function parseRequest(KernelMessageUri $uri = null)
43
    {
44
        $this->uri = is_null($uri) ? new KernelMessageUri() : $uri;
0 ignored issues
show
Documentation Bug introduced by
It seems like is_null($uri) ? new O2Sy...tp\Message\Uri() : $uri of type O2System\Kernel\Http\Message\Uri is incompatible with the declared type O2System\Kernel\Http\Router\Uri of property $uri.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
45
        $uriSegments = $this->uri->getSegments()->getParts();
46
        $uriString = $this->uri->getSegments()->getString();
47
48
        if ($this->uri->getSegments()->getTotalParts()) {
49
            if (strpos(end($uriSegments), '.json') !== false) {
50
                output()->setContentType('application/json');
0 ignored issues
show
Bug introduced by
The method setContentType() does not exist on O2System\Kernel\Cli\Output. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
                output()->/** @scrutinizer ignore-call */ setContentType('application/json');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
                $endSegment = str_replace('.json', '', end($uriSegments));
52
                array_pop($uriSegments);
53
                array_push($uriSegments, $endSegment);
54
                $this->uri = $this->uri->withSegments(new KernelMessageUriSegments($uriSegments));
55
                $uriString = $this->uri->getSegments()->getString();
56
            } elseif (strpos(end($uriSegments), '.xml') !== false) {
57
                output()->setContentType('application/xml');
58
                $endSegment = str_replace('.xml', '', end($uriSegments));
59
                array_pop($uriSegments);
60
                array_push($uriSegments, $endSegment);
61
                $this->uri = $this->uri->withSegments(new KernelMessageUriSegments($uriSegments));
62
                $uriString = $this->uri->getSegments()->getString();
63
            }
64
        } else {
65
            $uriPath = urldecode(
66
                parse_url($_SERVER[ 'REQUEST_URI' ], PHP_URL_PATH)
67
            );
68
69
            $uriPathParts = explode('public/', $uriPath);
70
            $uriPath = end($uriPathParts);
71
72
            if ($uriPath !== '/') {
73
                $uriString = $uriPath;
74
                $uriSegments = array_filter(explode('/', $uriString));
75
76
                $this->uri = $this->uri->withSegments(new KernelMessageUriSegments($uriSegments));
77
                $uriString = $this->uri->getSegments()->getString();
78
            }
79
        }
80
81
        // Load app addresses config
82
        $this->addresses = config()->loadFile('addresses', true);
0 ignored issues
show
Bug introduced by
The method loadFile() does not exist on O2System\Kernel\Datastructures\Config. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

82
        $this->addresses = config()->/** @scrutinizer ignore-call */ loadFile('addresses', true);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
83
84
        if ($this->addresses instanceof KernelAddresses) {
85
            // Domain routing
86
            if (null !== ($domain = $this->addresses->getDomain())) {
87
                if (is_array($domain)) {
88
                    $uriSegments = array_merge($domain, $uriSegments);
89
                    $this->uri = $this->uri->withSegments(new KernelMessageUriSegments($uriSegments));
90
                    $uriString = $this->uri->getSegments()->getString();
91
                    $domain = reset($uriSegments);
92
                }
93
94
                if (false !== ($app = modules()->getApp($domain))) {
0 ignored issues
show
Bug introduced by
The method getApp() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

94
                if (false !== ($app = modules()->/** @scrutinizer ignore-call */ getApp($domain))) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
95
                    $this->registerModule($app);
0 ignored issues
show
Bug introduced by
It seems like $app can also be of type true; however, parameter $module of O2System\Framework\Http\Router::registerModule() does only seem to accept O2System\Framework\Conta...s\DataStructures\Module, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

95
                    $this->registerModule(/** @scrutinizer ignore-type */ $app);
Loading history...
96
                } elseif (false !== ($module = modules()->getModule($domain))) {
0 ignored issues
show
Bug introduced by
The method getModule() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

96
                } elseif (false !== ($module = modules()->/** @scrutinizer ignore-call */ getModule($domain))) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
97
                    $this->registerModule($module);
98
                }
99
            } elseif (false !== ($subdomain = $this->uri->getSubdomain())) {
100
                if (false !== ($app = modules()->getApp($subdomain))) {
101
                    $this->registerModule($app);
102
                }
103
            }
104
        }
105
106
        // Module routing
107
        if ($uriTotalSegments = count($uriSegments)) {
108
            for ($i = 0; $i <= $uriTotalSegments; $i++) {
109
                $uriRoutedSegments = array_diff($uriSegments,
110
                    array_slice($uriSegments, ($uriTotalSegments - $i)));
111
112
                if ( ! empty($app)) {
113
                    if (reset($uriSegments) !== $app->getParameter()) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $app does not seem to be defined for all execution paths leading up to this point.
Loading history...
114
                        array_unshift($uriRoutedSegments, $app->getParameter());
115
                    }
116
                }
117
118
                if (false !== ($module = modules()->getModule($uriRoutedSegments))) {
119
                    $uriSegments = array_diff($uriSegments, $uriRoutedSegments);
120
                    $this->uri = $this->uri->withSegments(new KernelMessageUriSegments($uriSegments));
121
                    $uriString = $this->uri->getSegments()->getString();
122
123
                    $this->registerModule($module);
124
125
                    break;
126
                }
127
            }
128
        }
129
130
        // Try to translate from uri string
131
        if (false !== ($action = $this->addresses->getTranslation($uriString))) {
0 ignored issues
show
Bug introduced by
The method getTranslation() does not exist on O2System\Spl\Datastructures\SplArrayObject. It seems like you code against a sub-type of O2System\Spl\Datastructures\SplArrayObject such as O2System\Framework\Model...\DataObjects\Result\Row. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

131
        if (false !== ($action = $this->addresses->/** @scrutinizer ignore-call */ getTranslation($uriString))) {
Loading history...
132
            if ( ! $action->isValidHttpMethod(input()->server('REQUEST_METHOD')) && ! $action->isAnyHttpMethod()) {
133
                output()->sendError(405);
134
            } else {
135
                // Checks if action closure is an array
136
                if (is_array($closureSegments = $action->getClosure())) {
137
                    // Closure App Routing
138
                    if (false !== ($app = modules()->getModule(reset($closureSegments)))) {
139
                        array_shift($closureSegments);
140
                        $this->registerModule($app);
141
                    }
142
143
                    // Closure Module routing
144
                    if ($numOfClosureSegments = count($closureSegments)) {
145
                        for ($i = 0; $i <= $numOfClosureSegments; $i++) {
146
                            $closureRoutedSegments = array_diff($closureSegments,
147
                                array_slice($closureSegments, ($numOfClosureSegments - $i)));
148
149
                            if ( ! empty($app)) {
150
                                if (reset($closureSegments) !== $app->getParameter()) {
151
                                    array_unshift($closureRoutedSegments, $app->getParameter());
152
                                }
153
                            }
154
155
                            if (false !== ($module = modules()->getModule($closureRoutedSegments))) {
156
                                $uriSegments = array_diff($closureSegments, $closureRoutedSegments);
157
                                $this->uri = $this->uri->withSegments(new KernelMessageUriSegments($closureSegments));
158
                                $uriString = $this->uri->getSegments()->getString();
159
160
                                $this->registerModule($module);
161
162
                                break;
163
                            }
164
                        }
165
                    }
166
                } else {
167
                    if (false !== ($parseSegments = $action->getParseUriString($uriString))) {
168
                        $uriSegments = $parseSegments;
169
                    } else {
170
                        $uriSegments = [];
171
                    }
172
173
                    $this->uri = $this->uri->withSegments(new KernelMessageUriSegments($uriSegments));
174
                    $uriString = $this->uri->getSegments()->getString();
175
176
                    $this->parseAction($action, $uriSegments);
0 ignored issues
show
Bug introduced by
It seems like $action can also be of type true; however, parameter $action of O2System\Framework\Http\Router::parseAction() does only seem to accept O2System\Kernel\Http\Router\DataStructures\Action, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

176
                    $this->parseAction(/** @scrutinizer ignore-type */ $action, $uriSegments);
Loading history...
177
                    if ( ! empty(services()->has('controller'))) {
178
                        return true;
179
                    }
180
                }
181
            }
182
        }
183
184
        // Try to get route from controller & page
185
        if ($uriTotalSegments = count($uriSegments)) {
186
            for ($i = 0; $i <= $uriTotalSegments; $i++) {
187
                $uriRoutedSegments = array_slice($uriSegments, 0, ($uriTotalSegments - $i));
188
                $modules = modules()->getArrayCopy();
0 ignored issues
show
Bug introduced by
The method getArrayCopy() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

188
                $modules = modules()->/** @scrutinizer ignore-call */ getArrayCopy();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
189
190
                foreach ($modules as $module) {
191
                    $controllerNamespace = $module->getNamespace() . 'Controllers\\';
192
                    if ($module->getNamespace() === 'O2System\Framework\\') {
193
                        $controllerNamespace = 'O2System\Framework\Http\Controllers\\';
194
                    }
195
196
                    if (false !== ($pagesDir = $module->getDir('pages', true))) {
197
                        $pageFilePath = $pagesDir . implode(DIRECTORY_SEPARATOR,
198
                                array_map('dash', $uriRoutedSegments)) . '.phtml';
199
200
                        if ( ! class_exists($controllerClassName = $controllerNamespace . 'Pages')) {
201
                            $controllerClassName = '\O2System\Framework\Http\Controllers\Pages';
202
                        } else {
203
                            $controller = new $controllerClassName();
204
205
                            /**
206
                             * Try to find from database
207
                             */
208
                            $modelClassName = str_replace('Controllers', 'Models', $controllerClassName);
209
210
                            if (class_exists($modelClassName)) {
211
                                models()->load($modelClassName, 'controller');
0 ignored issues
show
Bug introduced by
The method load() does not exist on O2System\Framework\Models\NoSql\Model. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

211
                                models()->/** @scrutinizer ignore-call */ load($modelClassName, 'controller');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method load() does not exist on O2System\Framework\Models\Sql\Model. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

211
                                models()->/** @scrutinizer ignore-call */ load($modelClassName, 'controller');
Loading history...
212
213
                                if (false !== ($page = models('controller')->find($uriString, 'segments'))) {
0 ignored issues
show
Bug introduced by
The method find() does not exist on O2System\Framework\Containers\Models. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

213
                                if (false !== ($page = models('controller')->/** @scrutinizer ignore-call */ find($uriString, 'segments'))) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
214
                                    if (isset($page->content)) {
215
                                        presenter()->partials->offsetSet('content', $page->content);
216
217
                                        $this->setController(
218
                                            (new KernelControllerDataStructure($controller))
219
                                                ->setRequestMethod('index')
220
                                        );
221
222
                                        return true;
223
                                        break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
224
                                    }
225
                                }
226
                            }
227
                        }
228
229
                        /**
230
                         * Try to find from page file
231
                         */
232
                        if (is_file($pageFilePath)) {
233
                            presenter()->page->setFile($pageFilePath);
234
                        } else {
235
                            $pageFilePath = str_replace('.phtml', DIRECTORY_SEPARATOR . 'index.phtml', $pageFilePath);
236
                            if(is_file($pageFilePath)) {
237
                                presenter()->page->setFile($pageFilePath);
238
                            }
239
                        }
240
241
                        if(presenter()->page->file instanceof SplFileInfo) {
242
                            $this->setController(
243
                                (new KernelControllerDataStructure($controllerClassName))
244
                                    ->setRequestMethod('index')
245
                            );
246
247
                            return true;
248
                            break;
249
                        }
250
                    }
251
252
                    if (class_exists($controllerClassName = $controllerNamespace . implode('\\',
253
                            array_map('studlycase', $uriRoutedSegments)))) {
254
                        $uriSegments = array_diff($uriSegments, $uriRoutedSegments);
255
                        $this->setController(new KernelControllerDataStructure($controllerClassName),
256
                            $uriSegments);
257
                        break;
258
                    }
259
                }
260
261
                // break the loop if the controller has been set
262
                if (services()->has('controller')) {
263
                    return true;
264
                    break;
265
                }
266
            }
267
        }
268
269
        if (class_exists($controllerClassName = modules()->current()->getDefaultControllerClassName())) {
0 ignored issues
show
Bug introduced by
The method current() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

269
        if (class_exists($controllerClassName = modules()->/** @scrutinizer ignore-call */ current()->getDefaultControllerClassName())) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
270
            $this->setController(new KernelControllerDataStructure($controllerClassName),
271
                $uriSegments);
272
273
            return true;
274
        }
275
276
        // Let's the framework do the rest when there is no controller found
277
        // the framework will redirect to PAGE 404
278
    }
279
280
    // ------------------------------------------------------------------------
281
282
    /**
283
     * Router::registerModule
284
     *
285
     * @param FrameworkModuleDataStructure $module
286
     */
287
    final public function registerModule(FrameworkModuleDataStructure $module)
288
    {
289
        // Push Subdomain App Module
290
        modules()->push($module);
0 ignored issues
show
Bug introduced by
The method push() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

290
        modules()->/** @scrutinizer ignore-call */ push($module);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
291
292
        // Load modular addresses config
293
        if (false !== ($configDir = $module->getDir('config', true))) {
294
            unset($addresses);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $addresses seems to be never defined.
Loading history...
295
296
            $reconfig = false;
297
            if (is_file(
298
                $filePath = $configDir . ucfirst(
299
                        strtolower(ENVIRONMENT)
0 ignored issues
show
Bug introduced by
The constant O2System\Framework\Http\ENVIRONMENT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
300
                    ) . DIRECTORY_SEPARATOR . 'Addresses.php'
301
            )) {
302
                require($filePath);
303
                $reconfig = true;
304
            } elseif (is_file(
305
                $filePath = $configDir . 'Addresses.php'
306
            )) {
307
                require($filePath);
308
                $reconfig = true;
309
            }
310
311
            if ( ! $reconfig) {
312
                $controllerNamespace = $module->getNamespace() . 'Controllers\\';
313
                $controllerClassName = $controllerNamespace . studlycase($module->getParameter());
314
315
                if (class_exists($controllerClassName)) {
316
                    $this->addresses->any(
317
                        '/',
318
                        function () use ($controllerClassName) {
319
                            return new $controllerClassName();
320
                        }
321
                    );
322
                }
323
            } elseif (isset($addresses)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $addresses seems to never exist and therefore isset should always be false.
Loading history...
324
                $this->addresses = $addresses;
325
            }
326
        } else {
327
            $controllerNamespace = $module->getNamespace() . 'Controllers\\';
328
            $controllerClassName = $controllerNamespace . studlycase($module->getParameter());
329
330
            if (class_exists($controllerClassName)) {
331
                $this->addresses->any(
332
                    '/',
333
                    function () use ($controllerClassName) {
334
                        return new $controllerClassName();
335
                    }
336
                );
337
            }
338
        }
339
    }
340
341
    // ------------------------------------------------------------------------
342
343
    /**
344
     * Router::parseAction
345
     *
346
     * @param KernelActionDataStructure $action
347
     * @param array                     $uriSegments
348
     *
349
     * @throws \ReflectionException
350
     */
351
    protected function parseAction(KernelActionDataStructure $action, array $uriSegments = [])
352
    {
353
        ob_start();
354
        $closure = $action->getClosure();
355
        if (empty($closure)) {
356
            $closure = ob_get_contents();
357
        }
358
        ob_end_clean();
359
360
        if ($closure instanceof Controller) {
361
            $uriSegments = empty($uriSegments)
362
                ? $action->getClosureParameters()
363
                : $uriSegments;
364
            $this->setController(
365
                (new KernelControllerDataStructure($closure))
366
                    ->setRequestMethod('index'),
367
                $uriSegments
368
            );
369
        } elseif ($closure instanceof KernelControllerDataStructure) {
370
            $this->setController($closure, $action->getClosureParameters());
371
        } elseif (is_array($closure)) {
372
            $uri = (new KernelMessageUri())
0 ignored issues
show
Unused Code introduced by
The assignment to $uri is dead and can be removed.
Loading history...
373
                ->withSegments(new KernelMessageUriSegments(''))
374
                ->withQuery('');
375
            $this->parseRequest($this->uri->addSegments($closure));
376
        } else {
377
            if (class_exists($closure)) {
378
                $this->setController(
379
                    (new KernelControllerDataStructure($closure))
380
                        ->setRequestMethod('index'),
381
                    $uriSegments
382
                );
383
            } elseif (preg_match("/([a-zA-Z0-9\\\]+)(@)([a-zA-Z0-9\\\]+)/", $closure, $matches)) {
384
                $this->setController(
385
                    (new KernelControllerDataStructure($matches[ 1 ]))
386
                        ->setRequestMethod($matches[ 3 ]),
387
                    $uriSegments
388
                );
389
            } elseif (presenter()->theme->use === true) {
0 ignored issues
show
Bug introduced by
The property use does not seem to exist on O2System\Framework\Conta...Structures\Module\Theme.
Loading history...
390
                if ( ! presenter()->partials->offsetExists('content') && $closure !== '') {
391
                    presenter()->partials->offsetSet('content', $closure);
392
                }
393
394
                if (presenter()->partials->offsetExists('content')) {
395
                    profiler()->watch('VIEW_SERVICE_RENDER');
396
                    view()->render();
397
                    exit(EXIT_SUCCESS);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
398
                } else {
399
                    output()->sendError(204);
400
                    exit(EXIT_ERROR);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
401
                }
402
            } elseif (is_string($closure) && $closure !== '') {
403
                if (is_json($closure)) {
404
                    output()->setContentType('application/json');
405
                    output()->send($closure);
0 ignored issues
show
Bug introduced by
The method send() does not exist on O2System\Kernel\Cli\Output. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

405
                    output()->/** @scrutinizer ignore-call */ send($closure);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
406
                } else {
407
                    output()->send($closure);
408
                }
409
            } elseif (is_array($closure) || is_object($closure)) {
410
                output()->send($closure);
411
            } elseif (is_numeric($closure)) {
412
                output()->sendError($closure);
0 ignored issues
show
Bug introduced by
$closure of type string is incompatible with the type integer expected by parameter $code of O2System\Kernel\Cli\Output::sendError(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

412
                output()->sendError(/** @scrutinizer ignore-type */ $closure);
Loading history...
Bug introduced by
$closure of type string is incompatible with the type integer expected by parameter $code of O2System\Kernel\Http\Output::sendError(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

412
                output()->sendError(/** @scrutinizer ignore-type */ $closure);
Loading history...
413
            } else {
414
                output()->sendError(204);
415
                exit(EXIT_ERROR);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
416
            }
417
        }
418
    }
419
}