diff --git a/src/flextype/bootstrap.php b/src/flextype/bootstrap.php index 51f0a823..1c66080c 100755 --- a/src/flextype/bootstrap.php +++ b/src/flextype/bootstrap.php @@ -9,18 +9,22 @@ declare(strict_types=1); namespace Flextype; -use Flextype\Foundation\Flextype; use Flextype\Component\Registry\Registry; use Flextype\Component\Session\Session; +use Flextype\Foundation\Flextype; use Slim\Http\Environment; use Slim\Http\Uri; -use Whoops\Util\Misc; -use Whoops\Handler\PrettyPageHandler; use Whoops\Handler\JsonResponseHandler; +use Whoops\Handler\PrettyPageHandler; +use Whoops\Run; +use Whoops\Util\Misc; + use function date_default_timezone_set; use function error_reporting; use function file_exists; +use function flextype; use function function_exists; +use function get_class; use function mb_internal_encoding; use function mb_language; use function mb_regex_encoding; @@ -62,9 +66,8 @@ $flextype = Flextype::getInstance([ * Display Errors */ if ($registry->get('flextype.settings.errors.display')) { - $environment = new Environment($_SERVER); - $uri = Uri::createFromEnvironment($environment); + $uri = Uri::createFromEnvironment($environment); $prettyPageHandler = new PrettyPageHandler(); @@ -77,30 +80,30 @@ if ($registry->get('flextype.settings.errors.display')) { 'Request URI' => $environment->get('PATH_INFO') ?: '', ]); - $prettyPageHandler->addDataTable('Flextype Application (Request)', array( + $prettyPageHandler->addDataTable('Flextype Application (Request)', [ 'Path' => $uri->getPath(), 'URL' => (string) $uri, 'Query String' => $uri->getQuery() ?: '', 'Scheme' => $uri->getScheme() ?: '', 'Port' => $uri->getPort() ?: '', 'Host' => $uri->getHost() ?: '', - )); + ]); // Set Whoops to default exception handler - $whoops = new \Whoops\Run; + $whoops = new Run(); $whoops->pushHandler($prettyPageHandler); // Enable JsonResponseHandler when request is AJAX - if (Misc::isAjaxRequest()){ + if (Misc::isAjaxRequest()) { $whoops->pushHandler(new JsonResponseHandler()); } $whoops->register(); flextype()->container()['phpErrorHandler'] = - flextype()->container()['errorHandler'] = - function() use ($whoops) { - new WhoopsErrorHandler($whoops); + flextype()->container()['errorHandler'] = + static function () use ($whoops) { + return new WhoopsErrorHandler($whoops); }; flextype()->container()['whoops'] = $whoops; diff --git a/src/flextype/dependencies.php b/src/flextype/dependencies.php index f8320f37..0d476743 100644 --- a/src/flextype/dependencies.php +++ b/src/flextype/dependencies.php @@ -48,11 +48,15 @@ use League\Glide\ServerFactory; use Monolog\Handler\StreamHandler; use Monolog\Logger; use ParsedownExtra; +use Phpfastcache\Drivers\Apcu\Config; +use Phpfastcache\Helper\Psr16Adapter as Cache; use Thunder\Shortcode\ShortcodeFacade; + use function date; use function extension_loaded; -use Phpfastcache\Helper\Psr16Adapter as Cache; - +use function flextype; +use function in_array; +use function sys_get_temp_dir; /** * Supply a custom callable resolver, which resolves PSR-15 middlewares. @@ -101,7 +105,6 @@ flextype()->container()['slugify'] = static function () { flextype()->container()['cache'] = static function () { - $driver_name = flextype('registry')->get('flextype.settings.cache.driver'); if (! $driver_name || $driver_name === 'auto') { @@ -122,9 +125,9 @@ flextype()->container()['cache'] = static function () { { $config = []; - foreach (flextype('registry')->get('flextype.settings.cache.drivers.'. $driver_name) as $key => $value) { - if ($key == 'path' && in_array($driver_name, ['files', 'sqlite', 'leveldb'])) { - $config['path'] = (!empty($value)) ? PATH['tmp'] . '/' . $value : sys_get_temp_dir(); + foreach (flextype('registry')->get('flextype.settings.cache.drivers.' . $driver_name) as $key => $value) { + if ($key === 'path' && in_array($driver_name, ['files', 'sqlite', 'leveldb'])) { + $config['path'] = ! empty($value) ? PATH['tmp'] . '/' . $value : sys_get_temp_dir(); } else { $config[Strings::camel($key)] = $value; } @@ -135,7 +138,7 @@ flextype()->container()['cache'] = static function () { switch ($driver_name) { case 'apcu': - $config = new \Phpfastcache\Drivers\Apcu\Config(getDriverConfig($driver_name)); + $config = new Config(getDriverConfig($driver_name)); break; case 'cassandra': $config = new \Phpfastcache\Drivers\Cassandra\Config(getDriverConfig($driver_name)); @@ -276,7 +279,7 @@ flextype()->container()['images'] = static function () { $manipulators = [ new Orientation(), new Crop(), - new Size(2000*2000), + new Size(2000 * 2000), new Brightness(), new Contrast(), new Gamma(),