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 ( 9c3470...c852c0 )
by
unknown
02:52
created

Framework::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System PHP 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;
15
16
// ------------------------------------------------------------------------
17
18
/*
19
 * ---------------------------------------------------------------
20
 * ERROR REPORTING
21
 * ---------------------------------------------------------------
22
 *
23
 * Different environments will require different levels of error reporting.
24
 * By default development will show errors but testing and live will hide them.
25
 */
26
switch (strtoupper(ENVIRONMENT)) {
0 ignored issues
show
Bug introduced by
The constant O2System\ENVIRONMENT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
27
    case 'DEVELOPMENT':
28
        error_reporting(-1);
29
        ini_set('display_errors', 1);
30
        break;
31
    case 'TESTING':
32
    case 'PRODUCTION':
33
        ini_set('display_errors', 0);
34
        error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
35
        break;
36
    default:
37
        header('HTTP/1.1 503 Service Unavailable.', true, 503);
38
        echo 'The application environment is not set correctly.';
39
        exit(1); // EXIT_ERROR
40
}
41
42
/*
43
 *---------------------------------------------------------------
44
 * VENDOR PATH
45
 *---------------------------------------------------------------
46
 *
47
 * RealPath to vendor folder.
48
 *
49
 * WITH TRAILING SLASH!
50
 */
51
if ( ! defined('PATH_VENDOR')) {
52
    define('PATH_VENDOR', PATH_ROOT . 'vendor' . DIRECTORY_SEPARATOR);
0 ignored issues
show
Bug introduced by
The constant O2System\PATH_ROOT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
53
}
54
55
/*
56
 *---------------------------------------------------------------
57
 * FRAMEWORK PATH
58
 *---------------------------------------------------------------
59
 *
60
 * RealPath to framework folder.
61
 *
62
 * WITH TRAILING SLASH!
63
 */
64
if ( ! defined('PATH_FRAMEWORK')) {
65
    define('PATH_FRAMEWORK', __DIR__ . DIRECTORY_SEPARATOR);
66
}
67
68
/*
69
 *---------------------------------------------------------------
70
 * APP PATH
71
 *---------------------------------------------------------------
72
 *
73
 * RealPath to application folder.
74
 *
75
 * WITH TRAILING SLASH!
76
 */
77
if ( ! defined('PATH_APP')) {
78
    define('PATH_APP', PATH_ROOT . DIR_APP . DIRECTORY_SEPARATOR);
0 ignored issues
show
Bug introduced by
The constant O2System\DIR_APP was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
79
}
80
81
/*
82
 *---------------------------------------------------------------
83
 * PUBLIC PATH
84
 *---------------------------------------------------------------
85
 *
86
 * RealPath to public folder.
87
 *
88
 * WITH TRAILING SLASH!
89
 */
90
if ( ! defined('PATH_PUBLIC')) {
91
    define('PATH_PUBLIC', PATH_ROOT . DIR_PUBLIC . DIRECTORY_SEPARATOR);
0 ignored issues
show
Bug introduced by
The constant O2System\DIR_PUBLIC was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
92
}
93
94
/*
95
 *---------------------------------------------------------------
96
 * CACHE PATH
97
 *---------------------------------------------------------------
98
 *
99
 * RealPath to writable caching folder.
100
 *
101
 * WITH TRAILING SLASH!
102
 */
103
if ( ! defined('PATH_CACHE')) {
104
    define('PATH_CACHE', PATH_ROOT . DIR_CACHE . DIRECTORY_SEPARATOR);
0 ignored issues
show
Bug introduced by
The constant O2System\DIR_CACHE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
105
}
106
107
/*
108
 *---------------------------------------------------------------
109
 * STORAGE PATH
110
 *---------------------------------------------------------------
111
 *
112
 * RealPath to writable storage folder.
113
 *
114
 * WITH TRAILING SLASH!
115
 */
116
if ( ! defined('PATH_STORAGE')) {
117
    define('PATH_STORAGE', PATH_ROOT . DIR_STORAGE . DIRECTORY_SEPARATOR);
0 ignored issues
show
Bug introduced by
The constant O2System\DIR_STORAGE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
118
}
119
120
/*
121
 *---------------------------------------------------------------
122
 * RESOURCES PATH
123
 *---------------------------------------------------------------
124
 *
125
 * RealPath to writable resources folder.
126
 *
127
 * WITH TRAILING SLASH!
128
 */
129
if ( ! defined('PATH_RESOURCES')) {
130
    define('PATH_RESOURCES', PATH_ROOT . DIR_RESOURCES . DIRECTORY_SEPARATOR);
0 ignored issues
show
Bug introduced by
The constant O2System\DIR_RESOURCES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
131
}
132
133
134
/*
135
 *---------------------------------------------------------------
136
 * FRAMEWORK CONSTANTS
137
 *---------------------------------------------------------------
138
 */
139
require __DIR__ . '/Config/Constants.php';
140
141
/*
142
 *---------------------------------------------------------------
143
 * FRAMEWORK HELPERS
144
 *---------------------------------------------------------------
145
 */
146
require __DIR__ . '/Helpers/Framework.php';
147
148
/**
149
 * Class Framework
150
 *
151
 * @package O2System
152
 */
153
class Framework extends Kernel
154
{
155
    /**
156
     * Framework Container Models
157
     *
158
     * @var Framework\Containers\Models
159
     */
160
    public $models;
161
162
    /**
163
     * Framework Container Modules
164
     *
165
     * @var Framework\Containers\Modules
166
     */
167
    public $modules;
168
169
    // ------------------------------------------------------------------------
170
171
    /**
172
     * Framework::__construct
173
     *
174
     * @return Framework
175
     */
176
    protected function __construct()
177
    {
178
        parent::__construct();
179
180
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
181
            profiler()->watch('Starting O2System Framework');
182
        }
183
184
        // Add App Views Folder
185
        output()->addFilePath(PATH_APP);
186
187
        $this->services->load(Framework\Services\Hooks::class);
0 ignored issues
show
Bug introduced by
The property services is declared private in O2System\Kernel and cannot be accessed from this context.
Loading history...
188
189
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
190
            profiler()->watch('Starting Framework Services');
191
        }
192
193
        foreach (['Globals', 'Environment', 'Loader', 'Config'] as $serviceClassName) {
194
            if (class_exists('App\Kernel\Services\\' . $serviceClassName)) {
195
                $this->services->load('App\Kernel\Services\\' . $serviceClassName);
196
            } elseif (class_exists('O2System\Framework\Services\\' . $serviceClassName)) {
197
                $this->services->load('O2System\Framework\Services\\' . $serviceClassName);
198
            }
199
        }
200
201
        // Instantiate Models Container
202
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
203
            profiler()->watch('Starting Models Container');
204
        }
205
206
        $this->models = new Framework\Containers\Models();
207
208
        // Instantiate Cache Service
209
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
210
            profiler()->watch('Starting Cache Service');
211
        }
212
        $this->services->add(new Framework\Services\Cache(config('cache', true)), 'cache');
0 ignored issues
show
Bug introduced by
It seems like config('cache', true) can also be of type O2System\Framework\Services\Config; however, parameter $config of O2System\Framework\Services\Cache::__construct() does only seem to accept O2System\Cache\Datastructures\Config, 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

212
        $this->services->add(new Framework\Services\Cache(/** @scrutinizer ignore-type */ config('cache', true)), 'cache');
Loading history...
213
214
        // Instantiate Modules Container
215
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
216
            profiler()->watch('Starting Modules Container');
217
        }
218
        $this->modules = new Framework\Containers\Modules();
219
220
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
221
            profiler()->watch('Starting O2System Framework Hooks Pre System');
222
        }
223
        hooks()->callEvent(Framework\Services\Hooks::PRE_SYSTEM);
224
    }
225
226
    // ------------------------------------------------------------------------
227
228
    /**
229
     * Framework::__reconstruct
230
     */
231
    protected function __reconstruct()
232
    {
233
        // Modules default app
234
        if (null !== ($defaultApp = config('app'))) {
0 ignored issues
show
introduced by
The condition null !== $defaultApp = config('app') is always true.
Loading history...
235
            if (false !== ($defaultModule = modules()->getApp($defaultApp))) {
0 ignored issues
show
Bug introduced by
It seems like $defaultApp can also be of type O2System\Framework\Services\Config; however, parameter $segment of O2System\Framework\Containers\Modules::getApp() does only seem to accept string, 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

235
            if (false !== ($defaultModule = modules()->getApp(/** @scrutinizer ignore-type */ $defaultApp))) {
Loading history...
236
                // Register Domain App Module Namespace
237
                loader()->addNamespace($defaultModule->getNamespace(), $defaultModule->getRealPath());
238
239
                // Push Domain App Module
240
                modules()->push($defaultModule);
241
            } elseif (false !== ($defaultModule = modules()->getModule($defaultApp))) {
0 ignored issues
show
Bug introduced by
It seems like $defaultApp can also be of type O2System\Framework\Services\Config; however, parameter $segments of O2System\Framework\Containers\Modules::getModule() does only seem to accept array|string, 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

241
            } elseif (false !== ($defaultModule = modules()->getModule(/** @scrutinizer ignore-type */ $defaultApp))) {
Loading history...
242
                // Register Path Module Namespace
243
                loader()->addNamespace($defaultModule->getNamespace(), $defaultModule->getRealPath());
244
245
                // Push Path Module
246
                modules()->push($defaultModule);
247
            }
248
        }
249
250
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
251
            profiler()->watch('Calling Hooks Service: Post System');
252
        }
253
        hooks()->callEvent(Framework\Services\Hooks::POST_SYSTEM);
254
255
        if (is_cli()) {
256
            $this->cliHandler();
257
        } else {
258
            $this->httpHandler();
259
        }
260
    }
261
262
    // ------------------------------------------------------------------------
263
264
    /**
265
     * Framework::cliHandler
266
     *
267
     * @return void
268
     */
269
    private function cliHandler()
270
    {
271
        // Instantiate CLI Router Service
272
        $this->services->load(Framework\Cli\Router::class);
0 ignored issues
show
Bug introduced by
The type O2System\Framework\Cli\Router was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The property services is declared private in O2System\Kernel and cannot be accessed from this context.
Loading history...
273
274
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
275
            profiler()->watch('Parse Router Request');
276
        }
277
        router()->parseRequest();
278
279
        if ($commander = router()->getCommander()) {
0 ignored issues
show
Bug introduced by
The method getCommander() does not exist on O2System\Framework\Http\Router. ( Ignorable by Annotation )

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

279
        if ($commander = router()->/** @scrutinizer ignore-call */ getCommander()) {

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...
280
            if ($commander instanceof Kernel\Cli\Router\Datastructures\Commander) {
281
                // Autoload Language
282
                language()->loadFile($commander->getParameter());
283
                language()->loadFile($commander->getRequestMethod());
284
                language()->loadFile($commander->getParameter() . '/' . $commander->getRequestMethod());
285
286
                // Autoload Model
287
                foreach ($this->modules as $module) {
288
                    if (in_array($module->getType(), ['KERNEL', 'FRAMEWORK'])) {
289
                        continue;
290
                    }
291
                    $module->loadModel();
292
                }
293
294
                // Autoload Model
295
                $modelClassName = str_replace('Commanders', 'Models', $commander->getName());
296
297
                if (class_exists($modelClassName)) {
298
                    models()->load($modelClassName, 'commander');
0 ignored issues
show
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

298
                    models()->/** @scrutinizer ignore-call */ load($modelClassName, 'commander');
Loading history...
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

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

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...
299
                }
300
301
                // Initialize Controller
302
                if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
303
                    profiler()->watch('Calling Hooks Service: Pre Commander');
304
                }
305
                hooks()->callEvent(Framework\Services\Hooks::PRE_COMMANDER);
306
307
                if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
308
                    profiler()->watch('Instantiating Requested Commander: ' . $commander->getClass());
309
                }
310
                $requestCommander = $commander->getInstance();
311
312
                if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
313
                    profiler()->watch('Calling Hooks Service: Post Commander');
314
                }
315
                hooks()->callEvent(Framework\Services\Hooks::POST_COMMANDER);
316
317
                if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
318
                    profiler()->watch('Execute Requested Commander: ' . $commander->getClass());
319
                }
320
                $requestCommander->execute();
321
322
                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...
323
            }
324
        }
325
    }
326
327
    // ------------------------------------------------------------------------
328
329
    /**
330
     * Framework::httpHandler
331
     *
332
     * @return void
333
     */
334
    private function httpHandler()
335
    {
336
        // Instantiate Http Router Service
337
        $this->services->load(Framework\Http\Router::class);
0 ignored issues
show
Bug introduced by
The property services is declared private in O2System\Kernel and cannot be accessed from this context.
Loading history...
338
339
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
340
            profiler()->watch('Parse Router Request');
341
        }
342
        router()->parseRequest();
343
344
        if (config()->loadFile('session') === 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

344
        if (config()->/** @scrutinizer ignore-call */ loadFile('session') === 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...
345
346
            // Instantiate Session Service
347
            $session = new Session(config('session', true));
0 ignored issues
show
Bug introduced by
It seems like config('session', true) can also be of type O2System\Framework\Services\Config; however, parameter $config of O2System\Session::__construct() does only seem to accept O2System\Kernel\Datastructures\Config, 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

347
            $session = new Session(/** @scrutinizer ignore-type */ config('session', true));
Loading history...
348
            $session->setLogger($this->services->get('logger'));
349
350
            if ( ! $session->isStarted()) {
351
                $session->start();
352
            }
353
354
            $this->services->add($session, 'session');
355
356
            if ($session->has('language') and $this->services->has('language')) {
357
                language()->setDefault($session->get('language'));
358
            } else {
359
                $session->set('language', language()->getDefault());
360
            }
361
362
            if (config('security')->protection[ 'csrf' ] === true) {
0 ignored issues
show
Bug Best Practice introduced by
The property protection does not exist on O2System\Framework\Services\Config. Since you implemented __get, consider adding a @property annotation.
Loading history...
363
                $csrfProtection = new Security\Protections\Csrf();
364
                $this->services->add($csrfProtection, 'csrfProtection');
365
            }
366
367
            if (config('security')->protection[ 'xss' ] === true) {
368
                $csrfProtection = new Security\Protections\Xss();
0 ignored issues
show
Unused Code introduced by
The assignment to $csrfProtection is dead and can be removed.
Loading history...
369
                $this->services->add($xssProtection, 'xssProtection');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $xssProtection seems to be never defined.
Loading history...
370
            }
371
        }
372
373
        if (config()->loadFile('view') === true) {
374
            // Instantiate Http UserAgent Service
375
            $this->services->load(Framework\Http\UserAgent::class);
376
377
            // Instantiate Http View Service
378
            $this->services->load(Framework\Http\Parser::class);
379
380
            // Instantiate Http View Service
381
            $this->services->load(Framework\Http\View::class);
382
383
            // Instantiate Http Presenter Service
384
            $this->services->load(Framework\Http\Presenter::class);
385
            presenter()->initialize();
386
        }
387
388
        // Instantiate Http Middleware Service
389
        $this->services->load(Framework\Http\Middleware::class);
390
391
        if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
392
            profiler()->watch('Running Middleware Service: Pre Controller');
393
        }
394
        middleware()->run();
395
396
        if (false !== ($controller = $this->services->get('controller'))) {
397
            if ($controller instanceof Kernel\Http\Router\Datastructures\Controller) {
398
                $controllerParameter = dash($controller->getParameter());
399
                $controllerRequestMethod = dash($controller->getRequestMethod());
400
401
                // Autoload Language
402
                if ($this->services->has('language')) {
403
                    language()->loadFile($controller->getParameter());
404
                    language()->loadFile($controller->getRequestMethod());
405
                    language()->loadFile($controller->getParameter() . '/' . $controller->getRequestMethod());
406
                }
407
408
                // Autoload Model
409
                foreach ($this->modules as $module) {
410
                    if (in_array($module->getType(), ['KERNEL', 'FRAMEWORK'])) {
411
                        continue;
412
                    }
413
                    $module->loadModel();
414
                }
415
416
                // Autoload Model
417
                $modelClassName = str_replace(['Controllers', 'Presenters'], 'Models', $controller->getName());
418
419
                if (class_exists($modelClassName)) {
420
                    $this->models->register('controller', new $modelClassName());
0 ignored issues
show
Bug introduced by
'controller' of type string is incompatible with the type O2System\Spl\Containers\...ures\SplServiceRegistry expected by parameter $service of O2System\Framework\Containers\Models::register(). ( Ignorable by Annotation )

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

420
                    $this->models->register(/** @scrutinizer ignore-type */ 'controller', new $modelClassName());
Loading history...
Bug introduced by
new $modelClassName() of type object is incompatible with the type null|string expected by parameter $offset of O2System\Framework\Containers\Models::register(). ( Ignorable by Annotation )

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

420
                    $this->models->register('controller', /** @scrutinizer ignore-type */ new $modelClassName());
Loading history...
421
                }
422
423
                // Autoload Assets
424
                if (config()->loadFile('view') === true) {
425
                    $controllerAssets = [];
426
                    $controllerAssetsDirs = [];
427
428
                    // Autoload Assets
429
                    foreach ($this->modules as $module) {
430
                        if (in_array($module->getType(), ['KERNEL', 'FRAMEWORK'])) {
431
                            continue;
432
                        }
433
434
                        $controllerAssets[] = $module->getParameter();
435
                        $controllerAssetsDirs[] = $module->getParameter();
436
                    }
437
438
                    $controllerAssets = array_reverse($controllerAssets);
439
                    $controllerAssetsDirs = array_reverse($controllerAssetsDirs);
440
441
                    $controllerAssets[] = $controllerParameter;
442
                    $controllerAssetsDirs[] = $controllerParameter;
443
444
                    $controllerAssets[] = $controllerRequestMethod;
445
446
                    foreach ($controllerAssetsDirs as $controllerAssetsDir) {
447
                        $controllerAssets[] = $controllerAssetsDir . '/' . $controllerParameter;
448
                        $controllerAssets[] = $controllerAssetsDir . '/' . $controllerRequestMethod;
449
                        $controllerAssets[] = $controllerAssetsDir . '/' . $controllerParameter . '/' . $controllerRequestMethod;
450
                    }
451
452
                    // Autoload Presenter
453
                    $presenterClassName = str_replace('Controllers', 'Presenters', $controller->getName());
454
455
                    if (class_exists($presenterClassName)) {
456
                        $presenterClassObject = new $presenterClassName();
457
                        if ($presenterClassObject instanceof Framework\Http\Presenter) {
458
                            $this->services->add($presenterClassObject, 'presenter');
459
                        }
460
                    }
461
462
                    // Re-Initialize Presenter
463
                    presenter()->initialize()->assets->loadFiles(
0 ignored issues
show
Bug Best Practice introduced by
The property assets does not exist on O2System\Framework\Http\Presenter. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method loadFiles() does not exist on null. ( Ignorable by Annotation )

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

463
                    presenter()->initialize()->assets->/** @scrutinizer ignore-call */ 
464
                                                       loadFiles(

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...
464
                        [
465
                            'css' => $controllerAssets,
466
                            'js'  => $controllerAssets,
467
                        ]
468
                    );
469
                }
470
471
                // Initialize Controller
472
                if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
473
                    profiler()->watch('Calling Hooks Service: Pre Controller');
474
                }
475
476
                hooks()->callEvent(Framework\Services\Hooks::PRE_CONTROLLER);
477
478
                if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
479
                    profiler()->watch('Instantiating Requested Controller: ' . $controller->getClass());
480
                }
481
                $requestController = $controller->getInstance();
482
483
                if (method_exists($requestController, '__reconstruct')) {
484
                    $requestController->__reconstruct();
485
                } elseif (method_exists($requestController, 'initialize')) {
486
                    $requestController->initialize();
487
                }
488
489
                $this->services->add($requestController, 'controller');
490
491
                if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
492
                    profiler()->watch('Calling Middleware Service: Post Controller');
493
                }
494
                hooks()->callEvent(Framework\Services\Hooks::POST_CONTROLLER);
495
496
                $requestMethod = $controller->getRequestMethod();
497
                $requestMethodArgs = $controller->getRequestMethodArgs();
498
499
                // Call the requested controller method
500
                if (profiler() !== false) {
0 ignored issues
show
introduced by
The condition profiler() !== false is always true.
Loading history...
501
                    profiler()->watch('Execute Requested Controller Method');
502
                }
503
                ob_start();
504
                $requestControllerOutput = $requestController->__call($requestMethod, $requestMethodArgs);
505
506
                if (empty($requestControllerOutput)) {
507
                    $requestControllerOutput = ob_get_contents();
508
                    ob_end_clean();
509
                } elseif (is_bool($requestControllerOutput)) {
510
                    if ($requestController instanceof Framework\Http\Controllers\Restful) {
511
                        $requestController->sendError($requestControllerOutput);
512
                    } else {
513
                        if ($requestControllerOutput === true) {
514
                            output()->sendError(200);
515
                            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...
516
                        } elseif ($requestControllerOutput === false) {
0 ignored issues
show
introduced by
The condition $requestControllerOutput === false is always true.
Loading history...
517
                            output()->sendError(204);
518
                            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...
519
                        }
520
                    }
521
                } elseif (is_array($requestControllerOutput) or is_object($requestControllerOutput)) {
522
                    if ($requestController instanceof Framework\Http\Controllers\Restful) {
523
                        $requestController->sendPayload($requestControllerOutput);
524
                    } else {
525
                        output()->send($requestControllerOutput);
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

525
                        output()->/** @scrutinizer ignore-call */ send($requestControllerOutput);

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...
526
                    }
527
                } elseif (is_numeric($requestControllerOutput)) {
528
                    output()->sendError($requestControllerOutput);
529
                }
530
531
                if (empty($requestControllerOutput) or $requestControllerOutput === '') {
532
                    if ($requestController instanceof Framework\Http\Controllers\Restful) {
533
                        $requestController->sendError(204);
534
                    } elseif (config()->loadFile('view') === true) {
535
                        $filenames = [
536
                            $controllerRequestMethod,
537
                            $controllerParameter . DIRECTORY_SEPARATOR . $controllerRequestMethod,
538
                        ];
539
540
                        if ($controllerRequestMethod === 'index') {
541
                            array_unshift($filenames, $controllerParameter);
542
                        }
543
544
                        foreach ($filenames as $filename) {
545
                            if (view()->getFilePath($filename)) {
546
                                view()->load($filename);
547
                            }
548
                        }
549
550
                        if (presenter()->partials->offsetExists('content')) {
0 ignored issues
show
Bug Best Practice introduced by
The property partials does not exist on O2System\Framework\Http\Presenter. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method offsetExists() does not exist on null. ( Ignorable by Annotation )

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

550
                        if (presenter()->partials->/** @scrutinizer ignore-call */ offsetExists('content')) {

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...
551
                            view()->render();
552
                            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...
553
                        }
554
                    }
555
556
                    // Send default error 204 - No Content
557
                    output()->sendError(204);
558
                } elseif (is_string($requestControllerOutput)) {
559
                    if (is_json($requestControllerOutput)) {
560
                        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

560
                        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...
561
                        output()->send($requestControllerOutput);
562
                    } elseif (is_serialized($requestControllerOutput)) {
563
                        output()->send($requestControllerOutput);
564
                    } elseif (config('presenter', true)->enabled === true) {
0 ignored issues
show
Bug Best Practice introduced by
The property enabled does not exist on O2System\Framework\Services\Config. Since you implemented __get, consider adding a @property annotation.
Loading history...
565
                        presenter()->partials->offsetSet('content', $requestControllerOutput);
566
                        view()->render();
567
                    } else {
568
                        output()->send($requestControllerOutput);
569
                    }
570
                    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...
571
                }
572
            }
573
        }
574
575
        // Show Error (404) Page Not Found
576
        output()->sendError(404);
577
    }
578
}
579