Solved Engine::class phpcs problems

pull/531/head
fadrian06 1 year ago
parent bdca41d7e1
commit def0e65965

@ -1,7 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* Flight: An extensible micro-framework. * Flight: An extensible micro-framework.
* *
@ -9,6 +7,8 @@ declare(strict_types=1);
* @license MIT, http://flightphp.com/license * @license MIT, http://flightphp.com/license
*/ */
declare(strict_types=1);
namespace flight; namespace flight;
use Closure; use Closure;
@ -390,7 +390,11 @@ class Engine
// Run any before middlewares // Run any before middlewares
if (count($route->middleware) > 0) { if (count($route->middleware) > 0) {
foreach ($route->middleware as $middleware) { foreach ($route->middleware as $middleware) {
$middleware_object = (is_callable($middleware) === true ? $middleware : (method_exists($middleware, 'before') === true ? [ $middleware, 'before' ] : false)); $middleware_object = (is_callable($middleware) === true
? $middleware
: (method_exists($middleware, 'before') === true
? [$middleware, 'before']
: false));
if ($middleware_object === false) { if ($middleware_object === false) {
continue; continue;
@ -418,7 +422,15 @@ class Engine
// process the middleware in reverse order now // process the middleware in reverse order now
foreach (array_reverse($route->middleware) as $middleware) { foreach (array_reverse($route->middleware) as $middleware) {
// must be an object. No functions allowed here // must be an object. No functions allowed here
$middleware_object = is_object($middleware) === true && !($middleware instanceof Closure) && method_exists($middleware, 'after') === true ? [ $middleware, 'after' ] : false; $middleware_object = false;
if (
is_object($middleware) === true
&& !($middleware instanceof Closure)
&& method_exists($middleware, 'after') === true
) {
$middleware_object = [$middleware, 'after'];
}
// has to have the after method, otherwise just skip it // has to have the after method, otherwise just skip it
if ($middleware_object === false) { if ($middleware_object === false) {
@ -608,8 +620,7 @@ class Engine
->status(404) ->status(404)
->write( ->write(
'<h1>404 Not Found</h1>' . '<h1>404 Not Found</h1>' .
'<h3>The page you have requested could not be found.</h3>' . '<h3>The page you have requested could not be found.</h3>'
str_repeat(' ', 512)
) )
->send(); ->send();
} }

Loading…
Cancel
Save