Skip to content

Commit

Permalink
run cs-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Jan 2, 2024
1 parent faa4bab commit cd85ef0
Show file tree
Hide file tree
Showing 60 changed files with 272 additions and 222 deletions.
5 changes: 2 additions & 3 deletions Annotation/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#[\Attribute(\Attribute::TARGET_METHOD)]
final class Model extends Attachable
{
/** {@inheritdoc} */
public static $_types = [
'type' => 'string',
'groups' => '[string]',
Expand Down Expand Up @@ -60,8 +59,8 @@ final class Model extends Attachable
public function __construct(
array $properties = [],
string $type = Generator::UNDEFINED,
array $groups = null,
array $options = null,
?array $groups = null,
?array $options = null,
array $serializationContext = []
) {
parent::__construct($properties + [
Expand Down
3 changes: 1 addition & 2 deletions Annotation/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Security extends AbstractAnnotation
{
/** {@inheritdoc} */
public static $_types = [
'name' => 'string',
'scopes' => '[string]',
Expand All @@ -36,7 +35,7 @@ class Security extends AbstractAnnotation

public function __construct(
array $properties = [],
string $name = null,
?string $name = null,
array $scopes = []
) {
parent::__construct($properties + [
Expand Down
4 changes: 2 additions & 2 deletions ApiDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class ApiDocGenerator
/**
* @var ?string
*/
private $openApiVersion = null;
private $openApiVersion;

/** @var Generator */
private $generator;
Expand All @@ -60,7 +60,7 @@ final class ApiDocGenerator
* @param DescriberInterface[]|iterable $describers
* @param ModelDescriberInterface[]|iterable $modelDescribers
*/
public function __construct($describers, $modelDescribers, CacheItemPoolInterface $cacheItemPool = null, string $cacheItemId = null, Generator $generator = null)
public function __construct($describers, $modelDescribers, ?CacheItemPoolInterface $cacheItemPool = null, ?string $cacheItemId = null, ?Generator $generator = null)
{
$this->describers = $describers;
$this->modelDescribers = $modelDescribers;
Expand Down
3 changes: 1 addition & 2 deletions Controller/YamlDocumentationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Nelmio\ApiDocBundle\Controller;

use InvalidArgumentException;
use Nelmio\ApiDocBundle\Render\RenderOpenApi;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -36,7 +35,7 @@ public function __invoke(Request $request, string $area = 'default')
);

return $response->setCharset('UTF-8');
} catch (InvalidArgumentException $e) {
} catch (\InvalidArgumentException $e) {
throw new BadRequestHttpException(sprintf('Area "%s" is not supported as it isn\'t defined in config.', $area));
}
}
Expand Down
6 changes: 0 additions & 6 deletions DependencyInjection/NelmioApiDocExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@

final class NelmioApiDocExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container): void
{
$container->prependExtensionConfig('framework', ['property_info' => ['enabled' => true]]);
Expand All @@ -52,9 +49,6 @@ public function prepend(ContainerBuilder $container): void
}
}

/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration(new Configuration(), $configs);
Expand Down
8 changes: 4 additions & 4 deletions Describer/OpenApiPhpDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ public function describe(OA\OpenApi $api)
}

if (
!$annotation instanceof OA\Response &&
!$annotation instanceof OA\RequestBody &&
!$annotation instanceof OA\Parameter &&
!$annotation instanceof OA\ExternalDocumentation
!$annotation instanceof OA\Response
&& !$annotation instanceof OA\RequestBody
&& !$annotation instanceof OA\Parameter
&& !$annotation instanceof OA\ExternalDocumentation
) {
throw new \LogicException(sprintf('Using the annotation "%s" as a root annotation in "%s::%s()" is not allowed.', get_class($annotation), $method->getDeclaringClass()->name, $method->name));
}
Expand Down
2 changes: 1 addition & 1 deletion Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class Model
/**
* @param string[]|null $groups
*/
public function __construct(Type $type, array $groups = null, array $options = null, array $serializationContext = [])
public function __construct(Type $type, ?array $groups = null, ?array $options = null, array $serializationContext = [])
{
$this->type = $type;
$this->options = $options;
Expand Down
2 changes: 1 addition & 1 deletion Model/ModelRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class ModelRegistry
private OA\OpenApi $api;

/**
* @param ModelDescriberInterface[]|iterable $modelDescribers
* @param ModelDescriberInterface[]|iterable $modelDescribers
* @param array<string, array{type: string, groups: string[]|null}> $alternativeNames
*
* @internal
Expand Down
2 changes: 1 addition & 1 deletion ModelDescriber/Annotations/AnnotationsReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getPropertyName($reflection, string $default): string
return $this->openApiAnnotationsReader->getPropertyName($reflection, $default);
}

public function updateProperty($reflection, OA\Property $property, array $serializationGroups = null): void
public function updateProperty($reflection, OA\Property $property, ?array $serializationGroups = null): void
{
$this->openApiAnnotationsReader->updateProperty($reflection, $property, $serializationGroups);
$this->phpDocReader->updateProperty($reflection, $property);
Expand Down
4 changes: 1 addition & 3 deletions ModelDescriber/Annotations/OpenApiAnnotationsReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getPropertyName($reflection, string $default): string
return Generator::UNDEFINED !== $oaProperty->property ? $oaProperty->property : $default;
}

public function updateProperty($reflection, OA\Property $property, array $serializationGroups = null): void
public function updateProperty($reflection, OA\Property $property, ?array $serializationGroups = null): void
{
/** @var OA\Property|null $oaProperty */
if (!$oaProperty = $this->getAnnotation($property->_context, $reflection, OA\Property::class)) {
Expand All @@ -83,8 +83,6 @@ public function updateProperty($reflection, OA\Property $property, array $serial

/**
* @param \ReflectionClass|\ReflectionProperty|\ReflectionMethod $reflection
*
* @return mixed
*/
private function getAnnotation(Context $parentContext, $reflection, string $className)
{
Expand Down
6 changes: 0 additions & 6 deletions ModelDescriber/BazingaHateoasModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public function setModelRegistry(ModelRegistry $modelRegistry)
$this->JMSModelDescriber->setModelRegistry($modelRegistry);
}

/**
* {@inheritdoc}
*/
public function describe(Model $model, OA\Schema $schema): void
{
$this->JMSModelDescriber->describe($model, $schema);
Expand Down Expand Up @@ -106,9 +103,6 @@ private function getHateoasMetadata(Model $model)
return null;
}

/**
* {@inheritdoc}
*/
public function supports(Model $model): bool
{
return $this->JMSModelDescriber->supports($model) || null !== $this->getHateoasMetadata($model);
Expand Down
9 changes: 9 additions & 0 deletions ModelDescriber/EnumModelDescriber.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nelmio\ApiDocBundle\ModelDescriber;

use Nelmio\ApiDocBundle\Model\Model;
Expand Down
6 changes: 3 additions & 3 deletions ModelDescriber/FormModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
private bool $useValidationGroups;

public function __construct(
FormFactoryInterface $formFactory = null,
Reader $reader = null,
array $mediaTypes = null,
?FormFactoryInterface $formFactory = null,
?Reader $reader = null,
?array $mediaTypes = null,
bool $useValidationGroups = false
) {
$this->formFactory = $formFactory;
Expand Down
8 changes: 1 addition & 7 deletions ModelDescriber/JMSModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ public function __construct(
$this->contextFactory = $contextFactory;
}

/**
* {@inheritdoc}
*/
public function describe(Model $model, OA\Schema $schema)
{
$className = $model->getType()->getClassName();
Expand Down Expand Up @@ -211,7 +208,7 @@ public function getSerializationContext(Model $model): SerializationContext
return $context;
}

private function computeGroups(Context $context, array $type = null)
private function computeGroups(Context $context, ?array $type = null)
{
if (null === $type || true !== $this->propertyTypeUsesGroups($type)) {
return null;
Expand All @@ -230,9 +227,6 @@ private function computeGroups(Context $context, array $type = null)
return $groups;
}

/**
* {@inheritdoc}
*/
public function supports(Model $model): bool
{
$className = $model->getType()->getClassName();
Expand Down
4 changes: 2 additions & 2 deletions ModelDescriber/ObjectModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public function __construct(
?Reader $reader,
iterable $propertyDescribers,
array $mediaTypes,
NameConverterInterface $nameConverter = null,
?NameConverterInterface $nameConverter = null,
bool $useValidationGroups = false,
ClassMetadataFactoryInterface $classMetadataFactory = null
?ClassMetadataFactoryInterface $classMetadataFactory = null
) {
$this->propertyInfo = $propertyInfo;
$this->doctrineReader = $reader;
Expand Down
3 changes: 0 additions & 3 deletions NelmioApiDocBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

final class NelmioApiDocBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new ConfigurationPass());
Expand Down
4 changes: 2 additions & 2 deletions OpenApiPhp/ModelRegister.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(ModelRegistry $modelRegistry, array $mediaTypes)
$this->mediaTypes = $mediaTypes;
}

public function __invoke(Analysis $analysis, array $parentGroups = null)
public function __invoke(Analysis $analysis, ?array $parentGroups = null)
{
foreach ($analysis->annotations as $annotation) {
// @Model using the ref field
Expand Down Expand Up @@ -105,7 +105,7 @@ public function __invoke(Analysis $analysis, array $parentGroups = null)
}
}

private function getGroups(ModelAnnotation $model, array $parentGroups = null): ?array
private function getGroups(ModelAnnotation $model, ?array $parentGroups = null): ?array
{
if (null === $model->groups) {
return $parentGroups;
Expand Down
32 changes: 15 additions & 17 deletions OpenApiPhp/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@
* of swagger Annotation classes with the following convenience methods
* to get or create the respective Annotation instances if not found
*
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::getPath()
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::getSchema()
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::getProperty()
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::getOperation()
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::getOperationParameter()
* @see Util::getPath()
* @see Util::getSchema()
* @see Util::getProperty()
* @see Util::getOperation()
* @see Util::getOperationParameter()
*
* which in turn get or create the Annotation instances through the following more general methods
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::getChild()
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::getCollectionItem()
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::getIndexedCollectionItem()
* @see Util::getChild()
* @see Util::getCollectionItem()
* @see Util::getIndexedCollectionItem()
*
* which then searches for an existing Annotation through
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::searchCollectionItem()
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::searchIndexedCollectionItem()
* @see Util::searchCollectionItem()
* @see Util::searchIndexedCollectionItem()
*
* and if not found the Annotation creates it through
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::createCollectionItem()
* @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::createContext()
* @see Util::createCollectionItem()
* @see Util::createContext()
*
* The merge method @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::merge() has the main purpose to be able
* The merge method @see Util::merge() has the main purpose to be able
* to merge properties from an deeply nested array of Annotation properties in the structure of a
* generated swagger json decoded array.
*/
Expand Down Expand Up @@ -214,7 +214,6 @@ public static function getCollectionItem(OA\AbstractAnnotation $parent, $class,
* @see OA\AbstractAnnotation::$_nested
*
* @param string $class
* @param mixed $value
*/
public static function getIndexedCollectionItem(OA\AbstractAnnotation $parent, $class, $value): OA\AbstractAnnotation
{
Expand Down Expand Up @@ -259,7 +258,6 @@ public static function searchCollectionItem(array $collection, array $properties
* Search for an Annotation within the $collection that has its member $index set to $value.
*
* @param string $member
* @param mixed $value
*
* @return false|int|string
*/
Expand Down Expand Up @@ -312,7 +310,7 @@ public static function createChild(OA\AbstractAnnotation $parent, $class, array
*
* @see Context
*/
public static function createContext(array $properties = [], Context $parent = null): Context
public static function createContext(array $properties = [], ?Context $parent = null): Context
{
return new Context($properties, $parent);
}
Expand All @@ -322,7 +320,7 @@ public static function createContext(array $properties = [], Context $parent = n
*
* @see Context
*/
public static function createWeakContext(Context $parent = null, array $additionalProperties = []): Context
public static function createWeakContext(?Context $parent = null, array $additionalProperties = []): Context
{
$propsToCopy = [
'version',
Expand Down
2 changes: 1 addition & 1 deletion PropertyDescriber/ArrayPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(iterable $propertyDescribers = [])
$this->propertyDescribers = $propertyDescribers;
}

public function describe(array $types, OA\Schema $property, array $groups = null, ?OA\Schema $schema = null)
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null)
{
// BC layer for symfony < 5.3
$type = method_exists($types[0], 'getCollectionValueTypes') ?
Expand Down
2 changes: 1 addition & 1 deletion PropertyDescriber/BooleanPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BooleanPropertyDescriber implements PropertyDescriberInterface
{
use NullablePropertyTrait;

public function describe(array $types, OA\Schema $property, array $groups = null, ?OA\Schema $schema = null)
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null)
{
$property->type = 'boolean';
$this->setNullableProperty($types[0], $property, $schema);
Expand Down
2 changes: 1 addition & 1 deletion PropertyDescriber/CompoundPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(iterable $propertyDescribers)
$this->propertyDescribers = $propertyDescribers;
}

public function describe(array $types, OA\Schema $property, array $groups = null, ?OA\Schema $schema = null)
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null)
{
$property->oneOf = Generator::UNDEFINED !== $property->oneOf ? $property->oneOf : [];

Expand Down
2 changes: 1 addition & 1 deletion PropertyDescriber/DateTimePropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DateTimePropertyDescriber implements PropertyDescriberInterface
{
use NullablePropertyTrait;

public function describe(array $types, OA\Schema $property, array $groups = null, ?OA\Schema $schema = null)
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null)
{
$property->type = 'string';
$property->format = 'date-time';
Expand Down
2 changes: 1 addition & 1 deletion PropertyDescriber/FloatPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FloatPropertyDescriber implements PropertyDescriberInterface
{
use NullablePropertyTrait;

public function describe(array $types, OA\Schema $property, array $groups = null, ?OA\Schema $schema = null)
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null)
{
$property->type = 'number';
$property->format = 'float';
Expand Down
2 changes: 1 addition & 1 deletion PropertyDescriber/IntegerPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class IntegerPropertyDescriber implements PropertyDescriberInterface
{
use NullablePropertyTrait;

public function describe(array $types, OA\Schema $property, array $groups = null, ?OA\Schema $schema = null)
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null)
{
$property->type = 'integer';
$this->setNullableProperty($types[0], $property, $schema);
Expand Down
Loading

0 comments on commit cd85ef0

Please sign in to comment.