Merge pull request #1159 from nelmio/analysis-zG01nA

Apply fixes from StyleCI
This commit is contained in:
David Buchmann 2017-12-22 18:44:38 +01:00 committed by GitHub
commit ccf7a75ec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 41 additions and 8 deletions

View File

@ -23,7 +23,9 @@ final class Model extends AbstractAnnotation
'type' => 'string',
'groups' => '[string]',
];
public static $_required = ['type'];
public static $_parents = [
'Swagger\Annotations\Parameter',
'Swagger\Annotations\Response',

View File

@ -21,8 +21,11 @@ use Psr\Cache\CacheItemPoolInterface;
final class ApiDocGenerator
{
private $swagger;
private $describers;
private $modelDescribers;
private $cacheItemPool;
/**

View File

@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Response;
final class SwaggerUiController
{
private $apiDocGenerator;
private $twig;
public function __construct(ApiDocGenerator $apiDocGenerator, \Twig_Environment $twig)

View File

@ -40,7 +40,7 @@ trait PriorityTaggedServiceTrait
*/
private function findAndSortTaggedServices($tagName, ContainerBuilder $container)
{
$services = array();
$services = [];
foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tags) {
foreach ($tags as $attributes) {
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;

View File

@ -23,6 +23,7 @@ final class ApiPlatformDescriber extends ExternalDocDescriber
parent::__construct(function () use ($documentation, $normalizer, $urlGenerator) {
$baseContext = $urlGenerator->getContext();
$urlGenerator->setContext(new RequestContext());
try {
$basePath = $urlGenerator->generate('api_entrypoint');
} finally {

View File

@ -16,6 +16,7 @@ use EXSyst\Component\Swagger\Swagger;
class ExternalDocDescriber implements DescriberInterface
{
private $externalDoc;
private $overwrite;
/**

View File

@ -22,7 +22,9 @@ final class RouteDescriber implements DescriberInterface, ModelRegistryAwareInte
use ModelRegistryAwareTrait;
private $routeCollection;
private $controllerReflector;
private $routeDescribers;
/**

View File

@ -28,7 +28,9 @@ final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelReg
use ModelRegistryAwareTrait;
private $routeCollection;
private $controllerReflector;
private $annotationReader;
public function __construct(RouteCollection $routeCollection, ControllerReflector $controllerReflector, Reader $annotationReader, bool $overwrite = false)

View File

@ -16,6 +16,7 @@ use Symfony\Component\PropertyInfo\Type;
final class Model
{
private $type;
private $groups;
/**

View File

@ -20,9 +20,13 @@ use Symfony\Component\PropertyInfo\Type;
final class ModelRegistry
{
private $unregistered = [];
private $models = [];
private $names = [];
private $modelDescribers = [];
private $api;
/**

View File

@ -70,28 +70,33 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
if ('text' === $blockPrefix) {
$property->setType('string');
break;
}
if ('number' === $blockPrefix) {
$property->setType('number');
break;
}
if ('integer' === $blockPrefix) {
$property->setType('integer');
break;
}
if ('date' === $blockPrefix) {
$property->setType('string');
$property->setFormat('date');
break;
}
if ('datetime' === $blockPrefix) {
$property->setType('string');
$property->setFormat('date-time');
break;
}
@ -115,6 +120,7 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $subType), null);
$property->getItems()->setRef($this->modelRegistry->register($model));
$property->setExample(sprintf('[{%s}]', $subType));
break;
}
@ -129,6 +135,7 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
$property->setType('string');
$property->setFormat(sprintf('%s id', $entityClass));
}
break;
}
@ -136,6 +143,7 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
//if form type is not builtin in Form component.
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $formClass));
$property->setRef($this->modelRegistry->register($model));
break;
}
}

View File

@ -119,6 +119,7 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
public function supports(Model $model): bool
{
$className = $model->getType()->getClassName();
try {
if ($this->factory->getMetadataForClass($className)) {
return true;

View File

@ -11,8 +11,8 @@
namespace Nelmio\ApiDocBundle\ModelDescriber;
use EXSyst\Component\Swagger\Schema;
use EXSyst\Component\Swagger\Items;
use EXSyst\Component\Swagger\Schema;
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
use phpDocumentor\Reflection\DocBlockFactory;
use phpDocumentor\Reflection\DocBlockFactoryInterface;
@ -56,13 +56,15 @@ class PhpdocPropertyAnnotationReader
continue;
}
$title = $description->render();
if ($title) break;
if ($title) {
break;
}
}
}
if ($property->getTitle() === null && $title) {
if (null === $property->getTitle() && $title) {
$property->setTitle($title);
}
if ($property->getDescription() === null && $docBlock->getDescription() && $docBlock->getDescription()->render()) {
if (null === $property->getDescription() && $docBlock->getDescription() && $docBlock->getDescription()->render()) {
$property->setDescription($docBlock->getDescription()->render());
}
}

View File

@ -39,6 +39,7 @@ final class PhpDocDescriber implements RouteDescriberInterface
$classDocBlock = $this->docBlockFactory->create($reflectionMethod->getDeclaringClass());
} catch (\Exception $e) {
}
try {
$docBlock = $this->docBlockFactory->create($reflectionMethod);
} catch (\Exception $e) {

View File

@ -23,6 +23,7 @@ use Symfony\Component\Routing\RouteCollection;
class RouteDescriberTest extends AbstractDescriberTest
{
private $routes;
private $routeDescriber;
public function testIgnoreWhenNoController()

View File

@ -77,7 +77,7 @@ class FunctionalTest extends WebTestCase
{
$operation = $this->getOperation('/api/swagger/implicit', $method);
$this->assertEquals(array(new Tag('implicit')), $operation->getTags());
$this->assertEquals([new Tag('implicit')], $operation->getTags());
$responses = $operation->getResponses();
$this->assertTrue($responses->has('201'));

View File

@ -78,7 +78,7 @@ class JMSFunctionalTest extends WebTestCase
], $this->getModel('VirtualProperty')->toArray());
}
protected static function createKernel(array $options = array())
protected static function createKernel(array $options = [])
{
return new TestKernel(true);
}

View File

@ -17,7 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
class WebTestCase extends BaseWebTestCase
{
protected static function createKernel(array $options = array())
protected static function createKernel(array $options = [])
{
return new TestKernel();
}

View File

@ -20,6 +20,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
final class ControllerReflector
{
private $container;
private $controllerNameParser;
private $controllers = [];
@ -45,6 +46,7 @@ final class ControllerReflector
}
list($class, $method) = $callable;
try {
return new \ReflectionMethod($class, $method);
} catch (\ReflectionException $e) {
@ -61,6 +63,7 @@ final class ControllerReflector
}
list($class, $method) = $callable;
try {
return [new \ReflectionClass($class), new \ReflectionMethod($class, $method)];
} catch (\ReflectionException $e) {