From 0a1cef77ad9d1d67771677f1018d3bacdff3fc45 Mon Sep 17 00:00:00 2001 From: William Durand Date: Fri, 6 Mar 2015 11:19:08 +0100 Subject: [PATCH] cs --- Command/SwaggerDumpCommand.php | 3 +++ DataTypes.php | 2 +- .../SwaggerConfigCompilerPass.php | 9 +------ Extractor/ApiDocExtractor.php | 6 +++-- Extractor/CachingApiDocExtractor.php | 5 ++-- Extractor/HandlerInterface.php | 2 +- Formatter/RequestAwareSwaggerFormatter.php | 9 ++++--- Formatter/SwaggerFormatter.php | 24 +++++++++---------- Parser/CollectionParser.php | 6 ++--- Parser/FormErrorsParser.php | 2 +- Resources/views/method.html.twig | 2 +- Tests/Controller/ApiDocControllerTest.php | 1 - Tests/Extractor/CollectionDirectiveTest.php | 1 - Tests/Extractor/TestExtractor.php | 1 - .../Controller/ResourceController.php | 4 ++-- Tests/Fixtures/app/config/routing.yml | 2 +- Tests/Formatter/SwaggerFormatterTest.php | 6 +---- 17 files changed, 37 insertions(+), 48 deletions(-) diff --git a/Command/SwaggerDumpCommand.php b/Command/SwaggerDumpCommand.php index f5c0704..a502b79 100644 --- a/Command/SwaggerDumpCommand.php +++ b/Command/SwaggerDumpCommand.php @@ -66,6 +66,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand if ($input->getOption('list-only')) { $data = $this->getResourceList($apiDocs, $output); $this->dump($data, null, $input, $output); + return; } @@ -75,6 +76,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand throw new \InvalidArgumentException(sprintf('Resource "%s" does not exist.', $resource)); } $this->dump($data, $resource, $input, $output); + return; } @@ -110,6 +112,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand if (!$destination) { $output->writeln($content); + return; } diff --git a/DataTypes.php b/DataTypes.php index 60a6a4b..1df2190 100644 --- a/DataTypes.php +++ b/DataTypes.php @@ -43,7 +43,7 @@ class DataTypes /** * Returns true if the supplied `actualType` value is considered a primitive type. Returns false, otherwise. * - * @param string $type + * @param string $type * @return bool */ public static function isPrimitive($type) diff --git a/DependencyInjection/SwaggerConfigCompilerPass.php b/DependencyInjection/SwaggerConfigCompilerPass.php index 16c4e9c..eba2ae7 100644 --- a/DependencyInjection/SwaggerConfigCompilerPass.php +++ b/DependencyInjection/SwaggerConfigCompilerPass.php @@ -11,15 +11,8 @@ namespace Nelmio\ApiDocBundle\DependencyInjection; -use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Parameter; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\Filesystem\Exception\IOException; -use Symfony\Component\Filesystem\Filesystem; - /** * Compiler pass that configures the SwaggerFormatter instance. @@ -55,4 +48,4 @@ class SwaggerConfigCompilerPass implements CompilerPassInterface $formatter->addMethodCall('setAuthenticationConfig', array($authentication)); } } -} \ No newline at end of file +} diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index 56d6589..421d4a8 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -521,8 +521,8 @@ class ApiDocExtractor /** * Creates a human-readable version of the `actualType`. `subType` is taken into account. * - * @param string $actualType - * @param string $subType + * @param string $actualType + * @param string $subType * @return string */ protected function generateHumanReadableType($actualType, $subType) @@ -531,6 +531,7 @@ class ApiDocExtractor if (class_exists($subType)) { $parts = explode('\\', $subType); + return sprintf('object (%s)', end($parts)); } @@ -545,6 +546,7 @@ class ApiDocExtractor if (class_exists($subType)) { $parts = explode('\\', $subType); + return sprintf('array of objects (%s)', end($parts)); } diff --git a/Extractor/CachingApiDocExtractor.php b/Extractor/CachingApiDocExtractor.php index a9c22d6..cdf96a4 100644 --- a/Extractor/CachingApiDocExtractor.php +++ b/Extractor/CachingApiDocExtractor.php @@ -16,7 +16,6 @@ use Nelmio\ApiDocBundle\Util\DocCommentExtractor; use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Routing\RouterInterface; /** @@ -65,11 +64,11 @@ class CachingApiDocExtractor extends ApiDocExtractor $data = parent::all(); $this->cache->write(serialize($data), $resources); - + return $data; } return unserialize(file_get_contents($this->cacheFile)); } -} +} diff --git a/Extractor/HandlerInterface.php b/Extractor/HandlerInterface.php index 60ed166..a267243 100644 --- a/Extractor/HandlerInterface.php +++ b/Extractor/HandlerInterface.php @@ -20,7 +20,7 @@ interface HandlerInterface * Parse route parameters in order to populate ApiDoc. * * @param \Nelmio\ApiDocBundle\Annotation\ApiDoc $annotation - * @param array $annotations + * @param array $annotations * @param \Symfony\Component\Routing\Route $route * @param \ReflectionMethod $method */ diff --git a/Formatter/RequestAwareSwaggerFormatter.php b/Formatter/RequestAwareSwaggerFormatter.php index 049e9d2..49cbd35 100644 --- a/Formatter/RequestAwareSwaggerFormatter.php +++ b/Formatter/RequestAwareSwaggerFormatter.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\Formatter; - use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Symfony\Component\HttpFoundation\Request; @@ -33,7 +32,7 @@ class RequestAwareSwaggerFormatter implements FormatterInterface protected $formatter; /** - * @param Request $request + * @param Request $request * @param SwaggerFormatter $formatter */ public function __construct(Request $request, SwaggerFormatter $formatter) @@ -45,8 +44,8 @@ class RequestAwareSwaggerFormatter implements FormatterInterface /** * Format a collection of documentation data. * - * @param array $collection - * @param null $resource + * @param array $collection + * @param null $resource * @internal param $array [ApiDoc] $collection * @return string|array */ @@ -71,4 +70,4 @@ class RequestAwareSwaggerFormatter implements FormatterInterface { return $this->formatter->formatOne($annotation); } -} \ No newline at end of file +} diff --git a/Formatter/SwaggerFormatter.php b/Formatter/SwaggerFormatter.php index 89819e8..1d2d220 100644 --- a/Formatter/SwaggerFormatter.php +++ b/Formatter/SwaggerFormatter.php @@ -15,8 +15,6 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Nelmio\ApiDocBundle\DataTypes; use Nelmio\ApiDocBundle\Swagger\ModelRegistry; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Router; -use Symfony\Component\Routing\RouterInterface; /** * Produces Swagger-compliant resource lists and API declarations as defined here: @@ -79,8 +77,8 @@ class SwaggerFormatter implements FormatterInterface * * If resource is provided, an API declaration for that resource is produced. Otherwise, a resource listing is returned. * - * @param array|ApiDoc[] $collection - * @param null|string $resource + * @param array|ApiDoc[] $collection + * @param null|string $resource * @return string|array */ public function format(array $collection, $resource = null) @@ -95,7 +93,7 @@ class SwaggerFormatter implements FormatterInterface /** * Formats the collection into Swagger-compliant output. * - * @param array $collection + * @param array $collection * @return array */ public function produceResourceListing(array $collection) @@ -167,8 +165,8 @@ class SwaggerFormatter implements FormatterInterface /** * Format documentation data for one route. * - * @param ApiDoc $annotation - * return string|array + * @param ApiDoc $annotation + * return string|array * @throws \BadMethodCallException */ public function formatOne(ApiDoc $annotation) @@ -179,8 +177,8 @@ class SwaggerFormatter implements FormatterInterface /** * Formats collection to produce a Swagger-compliant API declaration for the given resource. * - * @param array $collection - * @param string $resource + * @param array $collection + * @param string $resource * @return array */ protected function produceApiDeclaration(array $collection, $resource) @@ -202,7 +200,6 @@ class SwaggerFormatter implements FormatterInterface $apiBag = array(); - foreach ($collection as $item) { /** @var $apiDoc ApiDoc */ @@ -373,6 +370,7 @@ class SwaggerFormatter implements FormatterInterface $path = preg_replace('/({.*?})/', '', $path); $path = trim(preg_replace('/[^0-9a-zA-Z]/', '-', $path), '-'); $path = preg_replace('/-+/', '-', $path); + return $path; } @@ -387,7 +385,7 @@ class SwaggerFormatter implements FormatterInterface /** * Formats query parameters to Swagger-compliant form. * - * @param array $input + * @param array $input * @return array */ protected function deriveQueryParameters(array $input) @@ -580,6 +578,7 @@ class SwaggerFormatter implements FormatterInterface $pattern = sprintf('#^%s#', preg_quote($this->basePath)); $subPath = preg_replace($pattern, '', $path); + return $subPath; } @@ -594,6 +593,7 @@ class SwaggerFormatter implements FormatterInterface { $resource = preg_replace('#/^#', '', $resource); $resource = $this->normalizeResourcePath($resource); + return sprintf('%s_%s', strtolower($method), $resource); } -} \ No newline at end of file +} diff --git a/Parser/CollectionParser.php b/Parser/CollectionParser.php index 0ef9c66..20741c0 100644 --- a/Parser/CollectionParser.php +++ b/Parser/CollectionParser.php @@ -24,7 +24,7 @@ class CollectionParser implements ParserInterface, PostParserInterface /** * Return true/false whether this class supports parsing the given class. * - * @param array $item containing the following fields: class, groups. Of which groups is optional + * @param array $item containing the following fields: class, groups. Of which groups is optional * * @return boolean */ @@ -47,7 +47,7 @@ class CollectionParser implements ParserInterface, PostParserInterface /** * @param array|string $item The string type of input to parse. - * @param array $parameters The previously-parsed parameters array. + * @param array $parameters The previously-parsed parameters array. * * @return array */ @@ -74,4 +74,4 @@ class CollectionParser implements ParserInterface, PostParserInterface return $parameters; } -} \ No newline at end of file +} diff --git a/Parser/FormErrorsParser.php b/Parser/FormErrorsParser.php index a42f7d9..9df4441 100644 --- a/Parser/FormErrorsParser.php +++ b/Parser/FormErrorsParser.php @@ -21,7 +21,7 @@ class FormErrorsParser implements ParserInterface, PostParserInterface /** * Return true/false whether this class supports parsing the given class. * - * @param array $item containing the following fields: class, groups. Of which groups is optional + * @param array $item containing the following fields: class, groups. Of which groups is optional * * @return boolean */ diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig index cee9d54..798408a 100644 --- a/Resources/views/method.html.twig +++ b/Resources/views/method.html.twig @@ -258,7 +258,7 @@ {% else %} {% endif %} - + Headers {% if acceptType %} diff --git a/Tests/Controller/ApiDocControllerTest.php b/Tests/Controller/ApiDocControllerTest.php index e3c955f..12863c6 100644 --- a/Tests/Controller/ApiDocControllerTest.php +++ b/Tests/Controller/ApiDocControllerTest.php @@ -9,7 +9,6 @@ namespace NelmioApiDocBundle\Tests\Controller; use Nelmio\ApiDocBundle\Tests\WebTestCase; - /** * Class ApiDocControllerTest * diff --git a/Tests/Extractor/CollectionDirectiveTest.php b/Tests/Extractor/CollectionDirectiveTest.php index 1666dc8..34deef8 100644 --- a/Tests/Extractor/CollectionDirectiveTest.php +++ b/Tests/Extractor/CollectionDirectiveTest.php @@ -1,6 +1,5 @@ formatter = $container->get('nelmio_api_doc.formatter.swagger_formatter'); } - public function testResourceListing() { @@ -99,7 +96,6 @@ class SwaggerFormatterTest extends WebTestCase $this->assertEquals($expected, $actual); - } /** @@ -988,4 +984,4 @@ With multiple lines.', ), ); } -} \ No newline at end of file +}