Skip to content

Commit

Permalink
Merge branch 'master' into jms_serilizer_nullable_typed_properties
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Jun 12, 2024
2 parents 0bee583 + c20a32e commit 46a6645
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 48 deletions.
9 changes: 3 additions & 6 deletions src/ApiDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ final class ApiDocGenerator
/** @var iterable|ModelDescriberInterface[] */
private $modelDescribers;

/** @var CacheItemPoolInterface|null */
private $cacheItemPool;
private ?CacheItemPoolInterface $cacheItemPool;

/** @var string */
private $cacheItemId;
private string $cacheItemId;

/** @var string[] */
private $alternativeNames = [];
Expand All @@ -53,8 +51,7 @@ final class ApiDocGenerator
*/
private $openApiVersion;

/** @var Generator */
private $generator;
private Generator $generator;

/**
* @param DescriberInterface[]|iterable $describers
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/SwaggerUiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Nelmio\ApiDocBundle\Controller;

use Nelmio\ApiDocBundle\Exception\RenderInvalidArgumentException;
use Nelmio\ApiDocBundle\Render\Html\AssetsMode;
use Nelmio\ApiDocBundle\Render\RenderOpenApi;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -35,7 +34,6 @@ public function __invoke(Request $request, string $area = 'default'): Response
try {
$response = new Response(
$this->renderOpenApi->renderFromRequest($request, RenderOpenApi::HTML, $area, [
'assets_mode' => AssetsMode::BUNDLE,
'ui_renderer' => $this->uiRenderer,
]),
Response::HTTP_OK,
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->ifTrue(function ($v) {
return 0 === count($v) || isset($v['path_patterns']) || isset($v['host_patterns']) || isset($v['documentation']);
})
->then(function ($v) {
->then(function ($v): array {
return ['default' => $v];
})
->end()
Expand Down
2 changes: 1 addition & 1 deletion src/Model/ModelRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private function generateModelName(Model $model): string
*/
private function modelToArray(Model $model): array
{
$getType = function (Type $type) use (&$getType) {
$getType = function (Type $type) use (&$getType): array {
return [
'class' => $type->getClassName(),
'built_in_type' => $type->getBuiltinType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,14 @@ class SymfonyConstraintAnnotationReader
{
use SetsContextTrait;

/**
* @var Reader|null
*/
private $annotationsReader;
private ?Reader $annotationsReader;

/**
* @var OA\Schema
*/
private $schema;

/**
* @var bool
*/
private $useValidationGroups;
private bool $useValidationGroups;

public function __construct(?Reader $annotationsReader, bool $useValidationGroups = false)
{
Expand Down
16 changes: 6 additions & 10 deletions src/ModelDescriber/ObjectModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,16 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
use ModelRegistryAwareTrait;
use ApplyOpenApiDiscriminatorTrait;

/** @var PropertyInfoExtractorInterface */
private $propertyInfo;
/** @var ClassMetadataFactoryInterface|null */
private $classMetadataFactory;
/** @var Reader|null */
private $doctrineReader;
private PropertyInfoExtractorInterface $propertyInfo;
private ?ClassMetadataFactoryInterface $classMetadataFactory;
private ?Reader $doctrineReader;
/** @var PropertyDescriberInterface|PropertyDescriberInterface[] */
private $propertyDescriber;
/** @var string[] */
private $mediaTypes;
private array $mediaTypes;
/** @var (NameConverterInterface&AdvancedNameConverterInterface)|null */
private $nameConverter;
/** @var bool */
private $useValidationGroups;
private ?NameConverterInterface $nameConverter;
private bool $useValidationGroups;

/**
* @param PropertyDescriberInterface|PropertyDescriberInterface[] $propertyDescribers
Expand Down
5 changes: 1 addition & 4 deletions tests/Functional/Entity/SymfonyConstraints80.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,7 @@ public function setPropertyLessThanOrEqual(int $propertyLessThanOrEqual): void
$this->propertyLessThanOrEqual = $propertyLessThanOrEqual;
}

/**
* @return array
*/
public static function fetchAllowedChoices()
public static function fetchAllowedChoices(): array
{
return ['choice1', 'choice2'];
}
Expand Down
5 changes: 1 addition & 4 deletions tests/Functional/Entity/SymfonyConstraints81.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ public function setPropertyLessThanOrEqual(int $propertyLessThanOrEqual): void
$this->propertyLessThanOrEqual = $propertyLessThanOrEqual;
}

/**
* @return array
*/
public static function fetchAllowedChoices()
public static function fetchAllowedChoices(): array
{
return ['choice1', 'choice2'];
}
Expand Down
5 changes: 1 addition & 4 deletions tests/Functional/Entity/VirtualProperty80.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ class VirtualProperty80
*/
private $id;

/**
* @var User
*/
private $user;
private User $user;

/**
* @Serializer\Accessor(getter="getFoo", setter="setFoo")
Expand Down
5 changes: 1 addition & 4 deletions tests/Functional/Entity/VirtualProperty81.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ class VirtualProperty81
#[Serializer\Expose]
private $id;

/**
* @var User
*/
private $user;
private User $user;

#[Serializer\Accessor(getter: 'getFoo', setter: 'setFoo')]
#[Serializer\Type('string')]
Expand Down
5 changes: 1 addition & 4 deletions tests/Functional/ModelDescriber/NameConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

class NameConverter implements AdvancedNameConverterInterface
{
/**
* @var MetadataAwareNameConverter
*/
private $inner;
private MetadataAwareNameConverter $inner;

public function __construct(MetadataAwareNameConverter $inner)
{
Expand Down
4 changes: 4 additions & 0 deletions tests/Functional/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Hateoas\Configuration\Embedded;
use JMS\SerializerBundle\JMSSerializerBundle;
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
use Nelmio\ApiDocBundle\Render\Html\AssetsMode;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\BazingaUser;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex80;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex81;
Expand Down Expand Up @@ -252,6 +253,9 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load

// Filter routes
$c->loadFromExtension('nelmio_api_doc', [
'html_config' => [
'assets_mode' => AssetsMode::BUNDLE,
],
'use_validation_groups' => boolval(self::USE_VALIDATION_GROUPS === $this->flag),
'documentation' => [
'info' => [
Expand Down

0 comments on commit 46a6645

Please sign in to comment.