From 11d94430d0477b70fa3b2c7f436de1241a04f2da Mon Sep 17 00:00:00 2001 From: MarcFRICOU Date: Wed, 21 Oct 2015 17:16:11 +0200 Subject: [PATCH] style: :lipstick: --- src/Command/Scan.php | 3 ++- src/OperationParser/LumenControllerOperationParser.php | 6 +++--- src/functions.php | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Command/Scan.php b/src/Command/Scan.php index 6b75cf5..6b7c746 100644 --- a/src/Command/Scan.php +++ b/src/Command/Scan.php @@ -2,6 +2,7 @@ namespace Iadvize\SwaggerizeFastRoute\Command; +use Iadvize\SwaggerizeFastRoute\OperationParser\LumenControllerOperationParser; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -54,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $routeStream = 'php://output'; } - $operationParser = new \Iadvize\SwaggerizeFastRoute\OperationParser\LumenControllerOperationParser($controllerNamespace); + $operationParser = new LumenControllerOperationParser($controllerNamespace); $routes = \Iadvize\SwaggerizeFastRoute\scan($swaggerFile, $operationParser); diff --git a/src/OperationParser/LumenControllerOperationParser.php b/src/OperationParser/LumenControllerOperationParser.php index 0790a9c..c76e213 100644 --- a/src/OperationParser/LumenControllerOperationParser.php +++ b/src/OperationParser/LumenControllerOperationParser.php @@ -56,9 +56,9 @@ public function getHandler(OperationReference $operation) $paths = explode('/', $path); // path start with a / unset($paths[0]); - foreach ($paths as &$path) { - $path[0] = strtoupper($path[0]); - } + $paths = array_map(function ($path) { + return ucfirst($path); + }, $paths); // path to 'relative' namespace $path = implode('\\', $paths); diff --git a/src/functions.php b/src/functions.php index 6cb6810..6d35c09 100644 --- a/src/functions.php +++ b/src/functions.php @@ -80,6 +80,10 @@ function addRoutes($swaggerJson, RouteCollector $routeCollector, OperationParser */ function cacheRoutes(array $routes, $stream) { + if (is_writable($stream)) { + throw new \LogicException($stream . ' is not writable'); + } + $routeResource = fopen($stream, 'w'); $serializedRoutes = var_export($routes, true);