@@ -177,7 +177,7 @@ |
||
| 177 | 177 | public function setRedirectMode($redirectMode) |
| 178 | 178 | { |
| 179 | 179 | $redirectMode = (int)$redirectMode; |
| 180 | - if ($redirectMode < 300 || $redirectMode >= 400) { |
|
| 180 | + if ($redirectMode < 300 || $redirectMode >= 400) { |
|
| 181 | 181 | throw new InvalidArgumentException( |
| 182 | 182 | 'Invalid HTTP status for redirect mode' |
| 183 | 183 | ); |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use InvalidArgumentException; |
| 6 | 6 | |
| 7 | 7 | // From 'charcoal-translator' |
| 8 | -use Charcoal\Translator\Translation; |
|
| 9 | 8 | |
| 10 | 9 | // From 'charcoal-app' |
| 11 | 10 | use Charcoal\App\App; |
@@ -118,7 +118,7 @@ |
||
| 118 | 118 | { |
| 119 | 119 | if (!isset($this->routeManager)) { |
| 120 | 120 | $config = $this->config(); |
| 121 | - $routes = (isset($config['routes']) ? $config['routes'] : [] ); |
|
| 121 | + $routes = (isset($config['routes']) ? $config['routes'] : []); |
|
| 122 | 122 | |
| 123 | 123 | $this->routeManager = new RouteManager([ |
| 124 | 124 | 'config' => $routes, |
@@ -87,22 +87,22 @@ |
||
| 87 | 87 | $method = $matches[2]; |
| 88 | 88 | |
| 89 | 89 | if (is_object($context)) { |
| 90 | - $callable = [ $context, $method ]; |
|
| 90 | + $callable = [$context, $method]; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if (!is_callable($callable)) { |
| 94 | 94 | switch ($class) { |
| 95 | 95 | case '': |
| 96 | 96 | case 'self': |
| 97 | - $callable = [ $this, $method ]; |
|
| 97 | + $callable = [$this, $method]; |
|
| 98 | 98 | break; |
| 99 | 99 | |
| 100 | 100 | case 'static': |
| 101 | - $callable = [ static::class, $method ]; |
|
| 101 | + $callable = [static::class, $method]; |
|
| 102 | 102 | break; |
| 103 | 103 | |
| 104 | 104 | case 'parent': |
| 105 | - $callable = [ $this, 'parent::'.$method ]; |
|
| 105 | + $callable = [$this, 'parent::'.$method]; |
|
| 106 | 106 | break; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | foreach ($params as $key => $param) { |
| 55 | 55 | $setter = $this->setter($key); |
| 56 | 56 | |
| 57 | - if (!is_callable([ $this, $setter ])) { |
|
| 57 | + if (!is_callable([$this, $setter])) { |
|
| 58 | 58 | continue; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | * |
| 41 | 41 | * @var string[] |
| 42 | 42 | */ |
| 43 | - private $methods = [ 'GET' ]; |
|
| 43 | + private $methods = ['GET']; |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Response controller classname |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | public function processMultiplePaths($paths) |
| 39 | 39 | { |
| 40 | 40 | $paths = $this->parseAsArray($paths); |
| 41 | - $paths = array_map([ $this, 'filterPath' ], $paths); |
|
| 42 | - $paths = array_filter($paths, [ $this, 'pathExists' ]); |
|
| 41 | + $paths = array_map([$this, 'filterPath'], $paths); |
|
| 42 | + $paths = array_filter($paths, [$this, 'pathExists']); |
|
| 43 | 43 | |
| 44 | 44 | if ($paths === false) { |
| 45 | 45 | throw new InvalidArgumentException('Received invalid paths.'); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | $depth = 1; |
| 163 | 163 | $files = glob($pattern, $flags); |
| 164 | - foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR|GLOB_NOSORT)) as $dir) { |
|
| 164 | + foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR | GLOB_NOSORT)) as $dir) { |
|
| 165 | 165 | $files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags)); |
| 166 | 166 | $depth++; |
| 167 | 167 | if ($maxDepth > 0 && $depth >= $maxDepth) { |
@@ -60,8 +60,8 @@ |
||
| 60 | 60 | private function registerProviderFactory() |
| 61 | 61 | { |
| 62 | 62 | /** |
| 63 | - * @return Factory |
|
| 64 | - */ |
|
| 63 | + * @return Factory |
|
| 64 | + */ |
|
| 65 | 65 | if (!isset($this['provider/factory'])) { |
| 66 | 66 | $this['provider/factory'] = function () { |
| 67 | 67 | return new Factory([ |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | * @return Factory |
| 64 | 64 | */ |
| 65 | 65 | if (!isset($this['provider/factory'])) { |
| 66 | - $this['provider/factory'] = function () { |
|
| 66 | + $this['provider/factory'] = function() { |
|
| 67 | 67 | return new Factory([ |
| 68 | 68 | 'base_class' => ServiceProviderInterface::class, |
| 69 | 69 | 'resolver_options' => [ |
@@ -473,8 +473,8 @@ |
||
| 473 | 473 | $hash = isset($parts['fragment']) ? $parts['fragment'] : ''; |
| 474 | 474 | |
| 475 | 475 | $uri = $baseUrl->withPath($path) |
| 476 | - ->withQuery($query) |
|
| 477 | - ->withFragment($hash); |
|
| 476 | + ->withQuery($query) |
|
| 477 | + ->withFragment($hash); |
|
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | } |
@@ -14,7 +14,6 @@ discard block |
||
| 14 | 14 | use Slim\Http\Uri; |
| 15 | 15 | |
| 16 | 16 | // From 'league/climate' |
| 17 | -use League\CLImate\CLImate; |
|
| 18 | 17 | |
| 19 | 18 | // From Mustache |
| 20 | 19 | use Mustache_LambdaHelper as LambdaHelper; |
@@ -33,28 +32,20 @@ discard block |
||
| 33 | 32 | |
| 34 | 33 | // From 'charcoal-app' |
| 35 | 34 | use Charcoal\App\AppConfig; |
| 36 | - |
|
| 37 | 35 | use Charcoal\App\Action\ActionInterface; |
| 38 | -use Charcoal\App\Script\ScriptInterface; |
|
| 39 | 36 | use Charcoal\App\Module\ModuleInterface; |
| 40 | - |
|
| 41 | 37 | use Charcoal\App\Middleware\IpMiddleware; |
| 42 | - |
|
| 43 | 38 | use Charcoal\App\Route\ActionRoute; |
| 44 | 39 | use Charcoal\App\Route\RouteInterface; |
| 45 | 40 | use Charcoal\App\Route\TemplateRoute; |
| 46 | - |
|
| 47 | 41 | use Charcoal\App\Handler\Error; |
| 48 | 42 | use Charcoal\App\Handler\PhpError; |
| 49 | 43 | use Charcoal\App\Handler\Maintenance; |
| 50 | 44 | use Charcoal\App\Handler\NotAllowed; |
| 51 | 45 | use Charcoal\App\Handler\NotFound; |
| 52 | - |
|
| 53 | 46 | use Charcoal\App\Template\TemplateInterface; |
| 54 | -use Charcoal\App\Template\TemplateBuilder; |
|
| 55 | 47 | use Charcoal\App\Template\WidgetInterface; |
| 56 | 48 | use Charcoal\App\Template\WidgetBuilder; |
| 57 | - |
|
| 58 | 49 | use Charcoal\App\ServiceProvider\DatabaseServiceProvider; |
| 59 | 50 | use Charcoal\App\ServiceProvider\FilesystemServiceProvider; |
| 60 | 51 | use Charcoal\App\ServiceProvider\ScriptServiceProvider; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param Container $container |
| 122 | 122 | * @return boolean |
| 123 | 123 | */ |
| 124 | - $container['debug'] = function (Container $container) { |
|
| 124 | + $container['debug'] = function(Container $container) { |
|
| 125 | 125 | if (isset($container['config']['debug'])) { |
| 126 | 126 | $debug = !!$container['config']['debug']; |
| 127 | 127 | } elseif (isset($container['config']['dev_mode'])) { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param Container $container |
| 143 | 143 | * @return \Psr\Http\Message\UriInterface |
| 144 | 144 | */ |
| 145 | - $container['base-url'] = function (Container $container) { |
|
| 145 | + $container['base-url'] = function(Container $container) { |
|
| 146 | 146 | if (isset($container['config']['base_url'])) { |
| 147 | 147 | $baseUrl = $container['config']['base_url']; |
| 148 | 148 | } else { |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param Container $container A container instance. |
| 179 | 179 | * @return \Charcoal\App\Handler\HandlerInterface |
| 180 | 180 | */ |
| 181 | - $container->extend('notFoundHandler', function ($handler, Container $container) use ($config) { |
|
| 181 | + $container->extend('notFoundHandler', function($handler, Container $container) use ($config) { |
|
| 182 | 182 | if ($handler instanceof \Slim\Handlers\NotFound) { |
| 183 | 183 | $notFoundConfig = isset($config['notFound']) ? $config['notFound'] : []; |
| 184 | 184 | $handler = new NotFound($container, $notFoundConfig); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param Container $container A container instance. |
| 198 | 198 | * @return \Charcoal\App\Handler\HandlerInterface |
| 199 | 199 | */ |
| 200 | - $container->extend('notAllowedHandler', function ($handler, Container $container) use ($config) { |
|
| 200 | + $container->extend('notAllowedHandler', function($handler, Container $container) use ($config) { |
|
| 201 | 201 | if ($handler instanceof \Slim\Handlers\NotAllowed) { |
| 202 | 202 | $notAllowedConfig = isset($config['notAllowed']) ? $config['notAllowed'] : []; |
| 203 | 203 | $handler = new NotAllowed($container, $notAllowedConfig); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * @param Container $container A container instance. |
| 217 | 217 | * @return \Charcoal\App\Handler\HandlerInterface |
| 218 | 218 | */ |
| 219 | - $container->extend('phpErrorHandler', function ($handler, Container $container) use ($config) { |
|
| 219 | + $container->extend('phpErrorHandler', function($handler, Container $container) use ($config) { |
|
| 220 | 220 | if ($handler instanceof \Slim\Handlers\PhpError) { |
| 221 | 221 | $phpErrorConfig = isset($config['phpError']) ? $config['phpError'] : []; |
| 222 | 222 | $handler = new PhpError($container, $phpErrorConfig); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param Container $container A container instance. |
| 236 | 236 | * @return \Charcoal\App\Handler\HandlerInterface |
| 237 | 237 | */ |
| 238 | - $container->extend('errorHandler', function ($handler, Container $container) use ($config) { |
|
| 238 | + $container->extend('errorHandler', function($handler, Container $container) use ($config) { |
|
| 239 | 239 | if ($handler instanceof \Slim\Handlers\Error) { |
| 240 | 240 | $errorConfig = isset($config['error']) ? $config['error'] : []; |
| 241 | 241 | $handler = new Error($container, $errorConfig); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @param Container $container A Pimple DI container. |
| 256 | 256 | * @return \Charcoal\App\Handler\HandlerInterface |
| 257 | 257 | */ |
| 258 | - $container['maintenanceHandler'] = function (Container $container) use ($config) { |
|
| 258 | + $container['maintenanceHandler'] = function(Container $container) use ($config) { |
|
| 259 | 259 | $maintenanceConfig = isset($config['maintenance']) ? $config['maintenance'] : []; |
| 260 | 260 | $handler = new Maintenance($container, $maintenanceConfig); |
| 261 | 261 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param Container $container A container instance. |
| 283 | 283 | * @return \Charcoal\Factory\FactoryInterface |
| 284 | 284 | */ |
| 285 | - $container['route/factory'] = function (Container $container) { |
|
| 285 | + $container['route/factory'] = function(Container $container) { |
|
| 286 | 286 | return new Factory([ |
| 287 | 287 | 'base_class' => RouteInterface::class, |
| 288 | 288 | 'resolver_options' => [ |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param Container $container A container instance. |
| 327 | 327 | * @return \Charcoal\Factory\FactoryInterface |
| 328 | 328 | */ |
| 329 | - $container['action/factory'] = function (Container $container) { |
|
| 329 | + $container['action/factory'] = function(Container $container) { |
|
| 330 | 330 | return new Factory([ |
| 331 | 331 | 'base_class' => ActionInterface::class, |
| 332 | 332 | 'resolver_options' => [ |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | * @param Container $container A container instance. |
| 350 | 350 | * @return \Charcoal\Factory\FactoryInterface |
| 351 | 351 | */ |
| 352 | - $container['template/factory'] = function (Container $container) { |
|
| 352 | + $container['template/factory'] = function(Container $container) { |
|
| 353 | 353 | return new Factory([ |
| 354 | 354 | 'base_class' => TemplateInterface::class, |
| 355 | 355 | 'resolver_options' => [ |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @param Container $container A container instance. |
| 372 | 372 | * @return \Charcoal\Factory\FactoryInterface |
| 373 | 373 | */ |
| 374 | - $container['widget/factory'] = function (Container $container) { |
|
| 374 | + $container['widget/factory'] = function(Container $container) { |
|
| 375 | 375 | return new Factory([ |
| 376 | 376 | 'base_class' => WidgetInterface::class, |
| 377 | 377 | 'resolver_options' => [ |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * @param Container $container A container instance. |
| 389 | 389 | * @return WidgetBuilder |
| 390 | 390 | */ |
| 391 | - $container['widget/builder'] = function (Container $container) { |
|
| 391 | + $container['widget/builder'] = function(Container $container) { |
|
| 392 | 392 | return new WidgetBuilder($container['widget/factory'], $container); |
| 393 | 393 | }; |
| 394 | 394 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | * @param Container $container A container instance. |
| 408 | 408 | * @return \Charcoal\Factory\FactoryInterface |
| 409 | 409 | */ |
| 410 | - $container['module/factory'] = function (Container $container) { |
|
| 410 | + $container['module/factory'] = function(Container $container) { |
|
| 411 | 411 | return new Factory([ |
| 412 | 412 | 'base_class' => ModuleInterface::class, |
| 413 | 413 | 'resolver_options' => [ |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | * @param Container $container A container instance. |
| 426 | 426 | * @return array |
| 427 | 427 | */ |
| 428 | - $container['module/classes'] = function (Container $container) { |
|
| 428 | + $container['module/classes'] = function(Container $container) { |
|
| 429 | 429 | $appConfig = $container['config']; |
| 430 | 430 | |
| 431 | 431 | $modules = $appConfig['modules']; |
@@ -435,11 +435,11 @@ discard block |
||
| 435 | 435 | 'suffix' => 'Module' |
| 436 | 436 | ]); |
| 437 | 437 | |
| 438 | - $modules = array_map(function ($module) use ($moduleResolver) { |
|
| 438 | + $modules = array_map(function($module) use ($moduleResolver) { |
|
| 439 | 439 | return $moduleResolver->resolve($module); |
| 440 | 440 | }, $modules); |
| 441 | 441 | |
| 442 | - array_filter($modules, function ($class) { |
|
| 442 | + array_filter($modules, function($class) { |
|
| 443 | 443 | return class_exists($class); |
| 444 | 444 | }); |
| 445 | 445 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | protected function registerViewServices(Container $container) |
| 457 | 457 | { |
| 458 | 458 | if (!isset($container['view/mustache/helpers'])) { |
| 459 | - $container['view/mustache/helpers'] = function () { |
|
| 459 | + $container['view/mustache/helpers'] = function() { |
|
| 460 | 460 | return []; |
| 461 | 461 | }; |
| 462 | 462 | } |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | * |
| 467 | 467 | * @return array |
| 468 | 468 | */ |
| 469 | - $container->extend('view/mustache/helpers', function (array $helpers, Container $container) { |
|
| 469 | + $container->extend('view/mustache/helpers', function(array $helpers, Container $container) { |
|
| 470 | 470 | $baseUrl = $container['base-url']; |
| 471 | 471 | $urls = [ |
| 472 | 472 | /** |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @param string $uri A URI path to wrap. |
| 494 | 494 | * @return UriInterface|null |
| 495 | 495 | */ |
| 496 | - 'withBaseUrl' => function ($uri, LambdaHelper $helper = null) use ($baseUrl) { |
|
| 496 | + 'withBaseUrl' => function($uri, LambdaHelper $helper = null) use ($baseUrl) { |
|
| 497 | 497 | if ($helper) { |
| 498 | 498 | $uri = $helper->render($uri); |
| 499 | 499 | } |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | } else { |
| 505 | 505 | $parts = parse_url($uri); |
| 506 | 506 | if (!isset($parts['scheme'])) { |
| 507 | - if (!in_array($uri[0], [ '/', '#', '?' ])) { |
|
| 507 | + if (!in_array($uri[0], ['/', '#', '?'])) { |
|
| 508 | 508 | $path = isset($parts['path']) ? $parts['path'] : ''; |
| 509 | 509 | $query = isset($parts['query']) ? $parts['query'] : ''; |
| 510 | 510 | $hash = isset($parts['fragment']) ? $parts['fragment'] : ''; |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | |
| 519 | 519 | return $uri; |
| 520 | 520 | }, |
| 521 | - 'renderContext' => function ($text, LambdaHelper $helper = null) { |
|
| 521 | + 'renderContext' => function($text, LambdaHelper $helper = null) { |
|
| 522 | 522 | return $helper->render('{{>'.$helper->render($text).'}}'); |
| 523 | 523 | } |
| 524 | 524 | ]; |
@@ -88,7 +88,7 @@ |
||
| 88 | 88 | /** |
| 89 | 89 | * Set the HTTP methods allowed by the current request. |
| 90 | 90 | * |
| 91 | - * @param array $methods Case-sensitive array of methods. |
|
| 91 | + * @param string[] $methods Case-sensitive array of methods. |
|
| 92 | 92 | * @return self |
| 93 | 93 | */ |
| 94 | 94 | protected function setMethods(array $methods) |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | |
| 80 | 80 | return $this->respondWith( |
| 81 | 81 | $response->withStatus($status) |
| 82 | - ->withHeader('Allow', $this->getMethods()), |
|
| 82 | + ->withHeader('Allow', $this->getMethods()), |
|
| 83 | 83 | $contentType, |
| 84 | 84 | $output |
| 85 | 85 | ); |