From 3b35a25871d92e42f1425e52b14989326b3d1533 Mon Sep 17 00:00:00 2001 From: Faizan Akram Date: Mon, 11 Dec 2023 12:13:38 +0100 Subject: [PATCH] cs-fix --- Tests/Functional/Controller/ApiController.php | 2 +- .../Functional/Controller/ApiController80.php | 58 +++++++++++++++++++ .../Controller/ArrayItemsErrorController.php | 2 + .../Controller/BazingaController.php | 4 ++ .../Controller/BazingaTypedController.php | 2 + .../Controller/ClassApiController.php | 8 ++- .../Controller/FOSRestController80.php | 2 + .../Controller/InvokableController.php | 5 +- Tests/Functional/Controller/JMSController.php | 18 ++++++ .../Controller/SerializedNameController.php | 8 ++- .../Functional/Controller/TestController.php | 5 +- .../Controller/UndocumentedController.php | 8 +-- Tests/Functional/Entity/Article.php | 3 +- Tests/Functional/Entity/CustomDateTime.php | 2 + .../Entity/EntityWithAlternateType.php | 14 ++--- .../Entity/EntityWithObjectType.php | 1 - Tests/Functional/Entity/JMSComplex.php | 12 ++++ .../Entity/JMSNamingStrategyConstraints.php | 3 + Tests/Functional/Entity/JMSNote.php | 2 + Tests/Functional/Entity/JMSUser.php | 32 ++++++++++ .../Functional/Entity/NestedGroup/JMSChat.php | 2 + .../Entity/NestedGroup/JMSChatFriend.php | 5 ++ .../Entity/NestedGroup/JMSChatLivingRoom.php | 1 + .../Entity/NestedGroup/JMSChatRoom.php | 5 ++ .../Entity/NestedGroup/JMSChatRoomUser.php | 3 + .../Entity/NestedGroup/JMSChatUser.php | 4 ++ .../Entity/NestedGroup/JMSPicture.php | 3 + .../Functional/Entity/SymfonyConstraints.php | 24 ++++---- ...SymfonyConstraintsWithValidationGroups.php | 7 ++- Tests/Functional/Entity/User.php | 4 +- Tests/Functional/Entity/VirtualProperty.php | 5 ++ .../EntityExcluded/ApiPlatform2/Dummy.php | 1 + .../Symfony7/SerializedNameEntity.php | 4 +- Tests/Functional/TestKernel.php | 27 ++------- Tests/Functional/WebTestCase.php | 1 - Tests/Model/ModelRegistryTest.php | 2 - .../Annotations/AnnotationReaderTest.php | 1 + .../SymfonyConstraintAnnotationReaderTest.php | 23 ++++++++ .../ApplyOpenApiDiscriminatorTraitTest.php | 4 +- Tests/Render/RenderOpenApiTest.php | 5 +- .../FilteredRouteCollectionBuilderTest.php | 2 + Tests/Util/ControllerReflectorTest.php | 5 +- 42 files changed, 250 insertions(+), 79 deletions(-) diff --git a/Tests/Functional/Controller/ApiController.php b/Tests/Functional/Controller/ApiController.php index 0dbf4efb3..798d2a286 100644 --- a/Tests/Functional/Controller/ApiController.php +++ b/Tests/Functional/Controller/ApiController.php @@ -15,7 +15,7 @@ use Symfony\Component\Routing\Annotation\Route; if (Kernel::MAJOR_VERSION >= 7) { - #[Route("/api", name: 'api_', host: 'api.example.com')] + #[Route('/api', name: 'api_', host: 'api.example.com')] class ApiController extends ApiController81 { } diff --git a/Tests/Functional/Controller/ApiController80.php b/Tests/Functional/Controller/ApiController80.php index a570ebf53..423aff1fd 100644 --- a/Tests/Functional/Controller/ApiController80.php +++ b/Tests/Functional/Controller/ApiController80.php @@ -39,14 +39,19 @@ class ApiController80 { /** * @OA\Get( + * * @OA\Response( * response="200", * description="Success", + * * @Model(type=Article::class, groups={"light"})) * ) * ) + * * @OA\Parameter(ref="#/components/parameters/test") + * * @Route("/article/{id}", methods={"GET"}) + * * @OA\Parameter(name="Accept-Version", in="header", @OA\Schema(type="string")) * @OA\Parameter(name="Application-Name", in="header", @OA\Schema(type="string")) */ @@ -56,14 +61,19 @@ public function fetchArticleAction() /** * @OA\Get( + * * @OA\Response( * response="200", * description="Success", + * * @Model(type=ArticleInterface::class, groups={"light"})) * ) * ) + * * @OA\Parameter(ref="#/components/parameters/test") + * * @Route("/article-interface/{id}", methods={"GET"}) + * * @OA\Parameter(name="Accept-Version", in="header", @OA\Schema(type="string")) * @OA\Parameter(name="Application-Name", in="header", @OA\Schema(type="string")) */ @@ -76,15 +86,21 @@ public function fetchArticleInterfaceAction() * * @Route("/swagger", methods={"GET", "LINK"}) * @Route("/swagger2", methods={"GET"}) + * * @Operation( + * * @OA\Response(response="201", description="An example resource") * ) + * * @OA\Get( * path="/api/swagger2", + * * @OA\Parameter(name="Accept-Version", in="header", @OA\Schema(type="string")) * ) + * * @OA\Post( * path="/api/swagger2", + * * @OA\Response(response="203", description="but 203 is not actually allowed (wrong method)") * ) */ @@ -94,18 +110,24 @@ public function swaggerAction() /** * @Route("/swagger/implicit", methods={"GET", "POST"}) + * * @OA\Response( * response="201", * description="Operation automatically detected", + * * @Model(type=User::class) * ), + * * @OA\RequestBody( * description="This is a request body", + * * @OA\JsonContent( * type="array", + * * @OA\Items(ref=@Model(type=User::class)) * ) * ) + * * @OA\Tag(name="implicit") */ public function implicitSwaggerAction() @@ -114,13 +136,17 @@ public function implicitSwaggerAction() /** * @Route("/test/users/{user}", methods={"POST"}, schemes={"https"}, requirements={"user"="/foo/"}) + * * @OA\Response( * response="201", * description="Operation automatically detected", + * * @Model(type=User::class) * ), + * * @OA\RequestBody( * description="This is a request body", + * * @Model(type=UserType::class, options={"bar": "baz"})) * ) */ @@ -130,6 +156,7 @@ public function submitUserTypeAction() /** * @Route("/test/{user}", methods={"GET"}, schemes={"https"}, requirements={"user"="/foo/"}) + * * @OA\Response(response=200, description="sucessful") */ public function userAction() @@ -161,6 +188,7 @@ public function adminAction() /** * @OA\Get( * path="/filtered", + * * @OA\Response(response="201", description="") * ) */ @@ -170,10 +198,13 @@ public function filteredAction() /** * @Route("/form", methods={"POST"}) + * * @OA\RequestBody( * description="Request content", + * * @Model(type=DummyType::class)) * ) + * * @OA\Response(response="201", description="") */ public function formAction() @@ -182,10 +213,13 @@ public function formAction() /** * @Route("/form-model", methods={"POST"}) + * * @OA\RequestBody( * description="Request content", + * * @Model(type=FormWithModel::class)) * ) + * * @OA\Response(response="201", description="") */ public function formWithModelAction() @@ -194,7 +228,9 @@ public function formWithModelAction() /** * @Route("/security") + * * @OA\Response(response="201", description="") + * * @Security(name="api_key") * @Security(name="basic") * @Security(name="oauth2", scopes={"scope_1"}) @@ -205,7 +241,9 @@ public function securityAction() /** * @Route("/securityOverride") + * * @OA\Response(response="201", description="") + * * @Security(name="api_key") * @Security(name=null) */ @@ -215,9 +253,11 @@ public function securityActionOverride() /** * @Route("/swagger/symfonyConstraints", methods={"GET"}) + * * @OA\Response( * response="201", * description="Used for symfony constraints test", + * * @Model(type=SymfonyConstraints::class) * ) */ @@ -235,6 +275,7 @@ public function symfonyConstraintsAction() * response="201", * ref="#/components/responses/201" * ) + * * @Route("/configReference", methods={"GET"}) */ public function configReferenceAction() @@ -243,7 +284,9 @@ public function configReferenceAction() /** * @Route("/multi-annotations", methods={"GET", "POST"}) + * * @OA\Get(description="This is the get operation") + * * @OA\Post(description="This is post") * * @OA\Response(response=200, description="Worked well!", @Model(type=DummyType::class)) @@ -301,7 +344,9 @@ public function namedRouteOperationIdAction() * @Route("/custom-operation-id", methods={"GET", "POST"}) * * @OA\Get(operationId="get-custom-operation-id") + * * @OA\Post(operationId="post-custom-operation-id") + * * @OA\Response(response=200, description="success") */ public function customOperationIdAction() @@ -310,9 +355,11 @@ public function customOperationIdAction() /** * @Route("/swagger/symfonyConstraintsWithValidationGroups", methods={"GET"}) + * * @OA\Response( * response="201", * description="Used for symfony constraints with validation groups test", + * * @Model(type=SymfonyConstraintsWithValidationGroups::class, groups={"test"}) * ) */ @@ -324,6 +371,7 @@ public function symfonyConstraintsWithGroupsAction() * @Route("/alternate-entity-type", methods={"GET", "POST"}) * * @OA\Get(operationId="alternate-entity-type") + * * @OA\Response(response=200, description="success", @OA\JsonContent( * ref=@Model(type=EntityWithAlternateType::class), * )) @@ -336,6 +384,7 @@ public function alternateEntityType() * @Route("/entity-with-ref", methods={"GET", "POST"}) * * @OA\Get(operationId="entity-with-ref") + * * @OA\Response(response=200, description="success", @OA\JsonContent( * ref=@Model(type=EntityWithRef::class), * )) @@ -348,6 +397,7 @@ public function entityWithRef() * @Route("/entity-with-object-type", methods={"GET", "POST"}) * * @OA\Get(operationId="entity-with-object-type") + * * @OA\Response(response=200, description="success", @OA\JsonContent( * ref=@Model(type=EntityWithObjectType::class), * )) @@ -358,11 +408,14 @@ public function entityWithObjectType() /** * @Route("/form-with-alternate-type", methods={"POST"}) + * * @OA\Response( * response="204", * description="Operation automatically detected", * ), + * * @OA\RequestBody( + * * @Model(type=FormWithAlternateSchemaType::class)) * ) */ @@ -372,11 +425,14 @@ public function formWithAlternateSchemaType() /** * @Route("/form-with-ref-type", methods={"POST"}) + * * @OA\Response( * response="204", * description="Operation automatically detected", * ), + * * @OA\RequestBody( + * * @Model(type=FormWithRefType::class)) * ) */ @@ -386,9 +442,11 @@ public function formWithRefSchemaType() /** * @Route("/entity-with-nullable-property-set", methods={"GET"}) + * * @OA\Response( * response="201", * description="Operation automatically detected", + * * @Model(type=EntityWithNullableSchemaSet::class) * ) */ diff --git a/Tests/Functional/Controller/ArrayItemsErrorController.php b/Tests/Functional/Controller/ArrayItemsErrorController.php index 00c5751d3..98da0cff3 100644 --- a/Tests/Functional/Controller/ArrayItemsErrorController.php +++ b/Tests/Functional/Controller/ArrayItemsErrorController.php @@ -23,9 +23,11 @@ class ArrayItemsErrorController { /** * @Route("/api/error", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=Foo::class) * ) */ diff --git a/Tests/Functional/Controller/BazingaController.php b/Tests/Functional/Controller/BazingaController.php index f8bb7d670..773605cdd 100644 --- a/Tests/Functional/Controller/BazingaController.php +++ b/Tests/Functional/Controller/BazingaController.php @@ -23,9 +23,11 @@ class BazingaController { /** * @Route("/api/bazinga", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=BazingaUser::class) * ) */ @@ -35,9 +37,11 @@ public function userAction() /** * @Route("/api/bazinga_foo", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=BazingaUser::class, groups={"foo"}) * ) */ diff --git a/Tests/Functional/Controller/BazingaTypedController.php b/Tests/Functional/Controller/BazingaTypedController.php index ad72687f3..377721ad4 100644 --- a/Tests/Functional/Controller/BazingaTypedController.php +++ b/Tests/Functional/Controller/BazingaTypedController.php @@ -23,9 +23,11 @@ class BazingaTypedController { /** * @Route("/api/bazinga_typed", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=BazingaUserTyped::class) * ) */ diff --git a/Tests/Functional/Controller/ClassApiController.php b/Tests/Functional/Controller/ClassApiController.php index a3a4b6d19..f2dc75184 100644 --- a/Tests/Functional/Controller/ClassApiController.php +++ b/Tests/Functional/Controller/ClassApiController.php @@ -20,12 +20,14 @@ if (Kernel::MAJOR_VERSION < 7) { /** * @Route("/api", host="api.example.com") + * * @Security(name="basic") */ class ClassApiController { /** * @Route("/security/class") + * * @OA\Response(response="201", description="") */ public function securityAction() @@ -34,13 +36,13 @@ public function securityAction() } } else { #[Security(name: 'basic')] - #[Route("/api", host: "api.example.com")] + #[Route('/api', host: 'api.example.com')] class ClassApiController { #[Response(response: 201, description: '')] - #[Route("/security/class")] + #[Route('/security/class')] public function securityAction() { } } -} \ No newline at end of file +} diff --git a/Tests/Functional/Controller/FOSRestController80.php b/Tests/Functional/Controller/FOSRestController80.php index 1e12df917..23352fa8e 100644 --- a/Tests/Functional/Controller/FOSRestController80.php +++ b/Tests/Functional/Controller/FOSRestController80.php @@ -22,8 +22,10 @@ class FOSRestController80 { /** * @Route("/fosrest.{_format}", methods={"POST"}) + * * @QueryParam(name="foo", requirements=@Regex("/^\d+$/")) * @QueryParam(name="mapped", map=true) + * * @RequestParam(name="Barraa", key="bar", requirements="\d+") * @RequestParam(name="baz", requirements=@IsTrue) * @RequestParam(name="datetime", requirements=@DateTime("Y-m-d\TH:i:sP")) diff --git a/Tests/Functional/Controller/InvokableController.php b/Tests/Functional/Controller/InvokableController.php index 86e4a9dbb..d91013a16 100644 --- a/Tests/Functional/Controller/InvokableController.php +++ b/Tests/Functional/Controller/InvokableController.php @@ -21,6 +21,7 @@ * Prevents a regression (see https://github.com/nelmio/NelmioApiDocBundle/issues/1559). * * @Route("/api/invoke", host="api.example.com", name="invokable", methods={"GET"}) + * * @OA\Response( * response=200, * description="Invokable!" @@ -37,11 +38,11 @@ public function __invoke() * Prevents a regression (see https://github.com/nelmio/NelmioApiDocBundle/issues/1559). */ #[Response(response: 200, description: 'Invokable!')] - #[Route("/api/invoke", host: "api.example.com", name: "invokable", methods: ["GET"])] + #[Route('/api/invoke', host: 'api.example.com', name: 'invokable', methods: ['GET'])] class InvokableController { public function __invoke() { } } -} \ No newline at end of file +} diff --git a/Tests/Functional/Controller/JMSController.php b/Tests/Functional/Controller/JMSController.php index 392eace10..2f377c7aa 100644 --- a/Tests/Functional/Controller/JMSController.php +++ b/Tests/Functional/Controller/JMSController.php @@ -31,9 +31,11 @@ class JMSController { /** * @Route("/api/jms", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=JMSUser::class) * ) */ @@ -43,9 +45,11 @@ public function userAction() /** * @Route("/api/yaml", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=VirtualProperty::class) * ) */ @@ -55,9 +59,11 @@ public function yamlAction() /** * @Route("/api/jms_complex", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=JMSComplex::class, groups={"list", "details", "User" : {"list"}}) * ) */ @@ -67,9 +73,11 @@ public function complexAction() /** * @Route("/api/jms_complex_dual", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=JMSDualComplex::class, groups={"Default", "complex" : {"User" : {"details"}}}) * ) */ @@ -79,9 +87,11 @@ public function complexDualAction() /** * @Route("/api/jms_naming_strategy", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=JMSNamingStrategyConstraints::class, groups={"Default"}) * ) */ @@ -91,9 +101,11 @@ public function namingStrategyConstraintsAction() /** * @Route("/api/jms_chat", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=JMSChat::class, groups={"Default", "members" : {"mini"}}) * ) */ @@ -103,9 +115,11 @@ public function chatAction() /** * @Route("/api/jms_picture", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=JMSPicture::class, groups={"mini"}) * ) */ @@ -115,9 +129,11 @@ public function pictureAction() /** * @Route("/api/jms_mini_user", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=JMSChatUser::class, groups={"mini"}) * ) */ @@ -127,9 +143,11 @@ public function minUserAction() /** * @Route("/api/jms_mini_user_nested", methods={"GET"}) + * * @OA\Response( * response=200, * description="Success", + * * @Model(type=JMSChatRoomUser::class, groups={"mini", "friend": {"living":{"Default"}}}) * ) */ diff --git a/Tests/Functional/Controller/SerializedNameController.php b/Tests/Functional/Controller/SerializedNameController.php index dd9f3fa7b..47cf8389a 100644 --- a/Tests/Functional/Controller/SerializedNameController.php +++ b/Tests/Functional/Controller/SerializedNameController.php @@ -31,8 +31,10 @@ class SerializedNameController * @OA\Response( * response="200", * description="success", + * * @Model(type=SerializedNameEnt::class) * ) + * * @Route("/serializename", methods={"GET"}) */ public function serializedNameAction() @@ -43,13 +45,13 @@ public function serializedNameAction() /** * This controller is only loaded when SerializedName exists (sf >= 4.2). */ - #[Route("/api", host: "api.example.com")] + #[Route('/api', host: 'api.example.com')] class SerializedNameController { #[Response(response: 200, description: 'success', attachables: [new Model(type: SerializedNameEntity::class)])] - #[Route("/serializename", methods: ["GET"])] + #[Route('/serializename', methods: ['GET'])] public function serializedNameAction() { } } -} \ No newline at end of file +} diff --git a/Tests/Functional/Controller/TestController.php b/Tests/Functional/Controller/TestController.php index 71bd8b1e4..77f33d288 100644 --- a/Tests/Functional/Controller/TestController.php +++ b/Tests/Functional/Controller/TestController.php @@ -27,6 +27,7 @@ class TestController * response="200", * description="Test" * ) + * * @Route("/test/", methods={"GET"}) */ public function testAction() @@ -38,9 +39,9 @@ public function testAction() class TestController { #[Response(response: 200, description: 'Test')] - #[Route("/test/", methods: ["GET"])] + #[Route('/test/', methods: ['GET'])] public function testAction() { } } -} \ No newline at end of file +} diff --git a/Tests/Functional/Controller/UndocumentedController.php b/Tests/Functional/Controller/UndocumentedController.php index 92904cb1e..37bdcdbdc 100644 --- a/Tests/Functional/Controller/UndocumentedController.php +++ b/Tests/Functional/Controller/UndocumentedController.php @@ -14,7 +14,6 @@ use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Routing\Annotation\Route; - if (Kernel::MAJOR_VERSION < 7) { /** * @Route(host="api.example.com") @@ -31,16 +30,15 @@ public function undocumentedAction() } } } else { - #[Route(host: "api.example.com")] + #[Route(host: 'api.example.com')] class UndocumentedController { /** * This path is excluded by the config (only /api allowed). - * */ - #[Route("/undocumented", methods: ["GET"])] + #[Route('/undocumented', methods: ['GET'])] public function undocumentedAction() { } } -} \ No newline at end of file +} diff --git a/Tests/Functional/Entity/Article.php b/Tests/Functional/Entity/Article.php index a67505b01..359ffc828 100644 --- a/Tests/Functional/Entity/Article.php +++ b/Tests/Functional/Entity/Article.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; -use Doctrine\Common\Annotations\AnnotationReader; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Serializer\Annotation\Groups; @@ -35,7 +34,7 @@ public function setContent(string $content) } else { class Article { - #[Groups(["light"])] + #[Groups(['light'])] public function setAuthor(User $author) { } diff --git a/Tests/Functional/Entity/CustomDateTime.php b/Tests/Functional/Entity/CustomDateTime.php index 7f027c538..09af078be 100644 --- a/Tests/Functional/Entity/CustomDateTime.php +++ b/Tests/Functional/Entity/CustomDateTime.php @@ -20,7 +20,9 @@ class CustomDateTime extends \DateTime { /** * @Serializer\Type("string") + * * @Serializer\Expose + * * @Serializer\SerializedName("format") */ private $format; diff --git a/Tests/Functional/Entity/EntityWithAlternateType.php b/Tests/Functional/Entity/EntityWithAlternateType.php index 9f5c03afd..eaf1aa20d 100644 --- a/Tests/Functional/Entity/EntityWithAlternateType.php +++ b/Tests/Functional/Entity/EntityWithAlternateType.php @@ -11,8 +11,6 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; -use ArrayIterator; -use IteratorAggregate; use OpenApi\Annotations as OA; use OpenApi\Attributes\Items; use OpenApi\Attributes\Schema; @@ -22,16 +20,16 @@ /** * @OA\Schema(type="array", @OA\Items(type="string")) */ - class EntityWithAlternateType implements IteratorAggregate + class EntityWithAlternateType implements \IteratorAggregate { /** * @var string */ public $ignored = 'this property should be ignored because of the annotation above'; - public function getIterator(): ArrayIterator + public function getIterator(): \ArrayIterator { - return new ArrayIterator([ + return new \ArrayIterator([ 'abc', 'def', ]); @@ -39,16 +37,16 @@ public function getIterator(): ArrayIterator } } else { #[Schema(type: 'array', items: new Items(type: 'string'))] - class EntityWithAlternateType implements IteratorAggregate + class EntityWithAlternateType implements \IteratorAggregate { /** * @var string */ public $ignored = 'this property should be ignored because of the annotation above'; - public function getIterator(): ArrayIterator + public function getIterator(): \ArrayIterator { - return new ArrayIterator([ + return new \ArrayIterator([ 'abc', 'def', ]); diff --git a/Tests/Functional/Entity/EntityWithObjectType.php b/Tests/Functional/Entity/EntityWithObjectType.php index 1d17f8cdb..00235ab77 100644 --- a/Tests/Functional/Entity/EntityWithObjectType.php +++ b/Tests/Functional/Entity/EntityWithObjectType.php @@ -15,7 +15,6 @@ use OpenApi\Attributes\Schema; use Symfony\Component\HttpKernel\Kernel; - if (Kernel::MAJOR_VERSION < 7) { /** * @OA\Schema(type="object") diff --git a/Tests/Functional/Entity/JMSComplex.php b/Tests/Functional/Entity/JMSComplex.php index 5cfcbba99..fcc7d199f 100644 --- a/Tests/Functional/Entity/JMSComplex.php +++ b/Tests/Functional/Entity/JMSComplex.php @@ -17,8 +17,10 @@ /** * @Serializer\ExclusionPolicy("all") + * * @OA\Schema( * required={"id", "user"}, + * * @OA\Property(property="virtual", ref=@Model(type=JMSUser::class)) * ) */ @@ -26,30 +28,40 @@ class JMSComplex { /** * @Serializer\Type("integer") + * * @Serializer\Expose + * * @Serializer\Groups({"list"}) */ private $id; /** * @OA\Property(ref=@Model(type=JMSUser::class)) + * * @Serializer\Expose + * * @Serializer\Groups({"details"}) + * * @Serializer\SerializedName("user") */ private $User; /** * @Serializer\Type("string") + * * @Serializer\Expose + * * @Serializer\Groups({"list"}) */ private $name; /** * @Serializer\VirtualProperty + * * @Serializer\Expose + * * @Serializer\Groups({"list"}) + * * @OA\Property(ref=@Model(type=JMSUser::class)) */ public function getVirtualFriend() diff --git a/Tests/Functional/Entity/JMSNamingStrategyConstraints.php b/Tests/Functional/Entity/JMSNamingStrategyConstraints.php index 1103e20eb..ca808ed7b 100644 --- a/Tests/Functional/Entity/JMSNamingStrategyConstraints.php +++ b/Tests/Functional/Entity/JMSNamingStrategyConstraints.php @@ -20,10 +20,13 @@ class JMSNamingStrategyConstraints * @var string * * @Serializer\Type("string") + * * @Serializer\SerializedName("beautifulName") * * @Assert\NotBlank() + * * @Assert\Regex(pattern="\w+") + * * @Assert\Length(min="3", max="10") */ private $some_weird_named_property = 'default'; diff --git a/Tests/Functional/Entity/JMSNote.php b/Tests/Functional/Entity/JMSNote.php index c2118f4d8..1ec6abb3c 100644 --- a/Tests/Functional/Entity/JMSNote.php +++ b/Tests/Functional/Entity/JMSNote.php @@ -22,12 +22,14 @@ class JMSNote { /** * @Serializer\Type("string") + * * @Serializer\Expose */ private $long; /** * @Serializer\Type("int") + * * @Serializer\Expose */ private $short; diff --git a/Tests/Functional/Entity/JMSUser.php b/Tests/Functional/Entity/JMSUser.php index 7189ac5c2..438124b78 100644 --- a/Tests/Functional/Entity/JMSUser.php +++ b/Tests/Functional/Entity/JMSUser.php @@ -23,7 +23,9 @@ class JMSUser { /** * @Serializer\Type("integer") + * * @Serializer\Expose + * * @Serializer\Groups({"list"}) * * @OA\Property(description = "User id", readOnly = true, title = "userid", example=1, default = null) @@ -32,7 +34,9 @@ class JMSUser /** * @Serializer\Type("int") + * * @Serializer\Expose + * * @Serializer\SerializedName("daysOnline") * * @OA\Property(default = 0, minimum = 1, maximum = 300) @@ -41,8 +45,11 @@ class JMSUser /** * @Serializer\Type("string") + * * @Serializer\Expose + * * @OA\Property(readOnly = false) + * * @Serializer\Groups({"details"}) */ private $email; @@ -53,7 +60,9 @@ class JMSUser * @var string[] * * @Serializer\Type("array") + * * @Serializer\Accessor(getter="getRoles", setter="setRoles") + * * @Serializer\Expose * * @OA\Property(default = {"user"}, description = "Roles list", example="[""ADMIN"",""SUPERUSER""]", title="roles") @@ -64,6 +73,7 @@ class JMSUser * User Location. * * @Serializer\Type("string") + * * @Serializer\Expose */ private $location; @@ -75,6 +85,7 @@ class JMSUser /** * @OA\Property(property="last_update", type="date") + * * @Serializer\Expose */ private $updatedAt; @@ -88,31 +99,37 @@ class JMSUser /** * @Serializer\Type("array") + * * @Serializer\Expose */ private $friends; /** * @Serializer\Type("array") + * * @Serializer\Expose */ private $indexedFriends; /** * @Serializer\Type("array") + * * @Serializer\Expose */ private $favoriteDates; /** * @Serializer\Type(Nelmio\ApiDocBundle\Tests\Functional\Entity\CustomDateTime::class) + * * @Serializer\Expose */ private $customDate; /** * @Serializer\Type("integer") + * * @Serializer\Expose + * * @Serializer\SerializedName("friendsNumber") * * @OA\Property(type = "string", minLength = 1, maxLength = 100) @@ -121,6 +138,7 @@ class JMSUser /** * @Serializer\Type(User::class) + * * @Serializer\Expose */ private $bestFriend; @@ -131,7 +149,9 @@ class JMSUser * Only enabled users may be used in actions. * * @var string + * * @Serializer\Type("string") + * * @Serializer\Expose * * @OA\Property(enum = {"disabled", "enabled"}) @@ -142,7 +162,9 @@ class JMSUser * JMS custom types handled via Custom Type Handlers. * * @var string + * * @Serializer\Type("VirtualTypeClassDoesNotExistsHandlerDefined") + * * @Serializer\Expose */ private $virtualType1; @@ -151,50 +173,60 @@ class JMSUser * JMS custom types handled via Custom Type Handlers. * * @var string + * * @Serializer\Type("VirtualTypeClassDoesNotExistsHandlerNotDefined") + * * @Serializer\Expose */ private $virtualType2; /** * @Serializer\Type("array>") + * * @Serializer\Expose */ private $latLonHistory; /** * @Serializer\Type("array") + * * @Serializer\Expose */ private $freeFormObject; /** * @Serializer\Type("array") + * * @Serializer\Expose */ private $freeFormObjectWithoutType; /** * @Serializer\Type("array>") + * * @Serializer\Expose */ private $deepObject; /** * @Serializer\Type("array>") + * * @Serializer\Expose */ private $deepObjectWithItems; /** * @Serializer\Type("array>>") + * * @Serializer\Expose */ private $deepFreeFormObjectCollection; /** * @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSNote") + * * @Serializer\Inline() + * * @Serializer\Expose */ private $notes; diff --git a/Tests/Functional/Entity/NestedGroup/JMSChat.php b/Tests/Functional/Entity/NestedGroup/JMSChat.php index 5373464fe..a36da193f 100644 --- a/Tests/Functional/Entity/NestedGroup/JMSChat.php +++ b/Tests/Functional/Entity/NestedGroup/JMSChat.php @@ -22,12 +22,14 @@ class JMSChat { /** * @Serializer\Type("integer") + * * @Serializer\Expose */ private $id; /** * @Serializer\Type("array") + * * @Serializer\Expose */ private $members; diff --git a/Tests/Functional/Entity/NestedGroup/JMSChatFriend.php b/Tests/Functional/Entity/NestedGroup/JMSChatFriend.php index 161337e79..fd0f7d3f4 100644 --- a/Tests/Functional/Entity/NestedGroup/JMSChatFriend.php +++ b/Tests/Functional/Entity/NestedGroup/JMSChatFriend.php @@ -22,20 +22,25 @@ class JMSChatFriend { /** * @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSChatRoom") + * * @Serializer\Expose + * * @Serializer\Groups({"mini"}) */ private $room; /** * @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSChatLivingRoom") + * * @Serializer\Expose + * * @Serializer\Groups({"Default", "mini"}) */ private $living; /** * @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSChatRoom") + * * @Serializer\Expose */ private $dining; diff --git a/Tests/Functional/Entity/NestedGroup/JMSChatLivingRoom.php b/Tests/Functional/Entity/NestedGroup/JMSChatLivingRoom.php index c47d6df29..307f55f43 100644 --- a/Tests/Functional/Entity/NestedGroup/JMSChatLivingRoom.php +++ b/Tests/Functional/Entity/NestedGroup/JMSChatLivingRoom.php @@ -22,6 +22,7 @@ class JMSChatLivingRoom { /** * @Serializer\Type("integer") + * * @Serializer\Expose */ private $id; diff --git a/Tests/Functional/Entity/NestedGroup/JMSChatRoom.php b/Tests/Functional/Entity/NestedGroup/JMSChatRoom.php index 76d4c43fc..f675e79e5 100644 --- a/Tests/Functional/Entity/NestedGroup/JMSChatRoom.php +++ b/Tests/Functional/Entity/NestedGroup/JMSChatRoom.php @@ -22,20 +22,25 @@ class JMSChatRoom { /** * @Serializer\Type("integer") + * * @Serializer\Expose + * * @Serializer\Groups({"Default"}) */ private $id1; /** * @Serializer\Type("integer") + * * @Serializer\Expose + * * @Serializer\Groups({"mini"}) */ private $id2; /** * @Serializer\Type("integer") + * * @Serializer\Expose */ private $id3; diff --git a/Tests/Functional/Entity/NestedGroup/JMSChatRoomUser.php b/Tests/Functional/Entity/NestedGroup/JMSChatRoomUser.php index 8aefae3ae..c0b57cf40 100644 --- a/Tests/Functional/Entity/NestedGroup/JMSChatRoomUser.php +++ b/Tests/Functional/Entity/NestedGroup/JMSChatRoomUser.php @@ -22,13 +22,16 @@ class JMSChatRoomUser { /** * @Serializer\Type("integer") + * * @Serializer\Expose */ private $id; /** * @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSChatFriend") + * * @Serializer\Expose + * * @Serializer\Groups({"mini"}) */ private $friend; diff --git a/Tests/Functional/Entity/NestedGroup/JMSChatUser.php b/Tests/Functional/Entity/NestedGroup/JMSChatUser.php index a220bfd3d..d5062f62d 100644 --- a/Tests/Functional/Entity/NestedGroup/JMSChatUser.php +++ b/Tests/Functional/Entity/NestedGroup/JMSChatUser.php @@ -22,19 +22,23 @@ class JMSChatUser { /** * @Serializer\Type("integer") + * * @Serializer\Expose */ private $id; /** * @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSPicture") + * * @Serializer\Groups({"mini"}) + * * @Serializer\Expose */ private $picture; /** * @Serializer\Type("array") + * * @Serializer\Expose */ private $allPictures; diff --git a/Tests/Functional/Entity/NestedGroup/JMSPicture.php b/Tests/Functional/Entity/NestedGroup/JMSPicture.php index 37650bbd6..3a2d70d5c 100644 --- a/Tests/Functional/Entity/NestedGroup/JMSPicture.php +++ b/Tests/Functional/Entity/NestedGroup/JMSPicture.php @@ -22,13 +22,16 @@ class JMSPicture { /** * @Serializer\Type("integer") + * * @Serializer\Expose */ private $id; /** * @Serializer\Type("integer") + * * @Serializer\Expose + * * @Serializer\Groups({"mini"}) */ private $onlyDirectPictureMini; diff --git a/Tests/Functional/Entity/SymfonyConstraints.php b/Tests/Functional/Entity/SymfonyConstraints.php index b802b460b..7a601a316 100644 --- a/Tests/Functional/Entity/SymfonyConstraints.php +++ b/Tests/Functional/Entity/SymfonyConstraints.php @@ -206,59 +206,55 @@ class SymfonyConstraints /** * @var int */ - #[Assert\NotBlank(groups: ["test"])] + #[Assert\NotBlank(groups: ['test'])] private $propertyNotBlank; /** * @var int - * */ #[Assert\NotNull()] private $propertyNotNull; /** * @var int - * */ - #[Assert\Length(min: "0", max: "50")] + #[Assert\Length(min: '0', max: '50')] private $propertyAssertLength; /** * @var int - * */ - #[Assert\Regex(pattern: "/[a-z]{2}/")] + #[Assert\Regex(pattern: '/[a-z]{2}/')] private $propertyRegex; /** * @var int - * */ - #[Assert\Count(min: "0", max: "10")] + #[Assert\Count(min: '0', max: '10')] private $propertyCount; /** * @var int */ - #[Assert\Choice(choices: ["choice1", "choice2"])] + #[Assert\Choice(choices: ['choice1', 'choice2'])] private $propertyChoice; /** * @var int */ - #[Assert\Choice(callback: [self::class, "fetchAllowedChoices"])] + #[Assert\Choice(callback: [self::class, 'fetchAllowedChoices'])] private $propertyChoiceWithCallback; /** * @var int */ - #[Assert\Choice(callback: "fetchAllowedChoices")] + #[Assert\Choice(callback: 'fetchAllowedChoices')] private $propertyChoiceWithCallbackWithoutClass; /** * @var string[] */ - #[Assert\Choice(multiple: true, choices: ["choice1", "choice2"])] + #[Assert\Choice(multiple: true, choices: ['choice1', 'choice2'])] private $propertyChoiceWithMultiple; /** @@ -266,7 +262,7 @@ class SymfonyConstraints */ #[Assert\Expression( "this.getCategory() in ['php', 'symfony'] or !this.isTechnicalPost()", - message: "If this is a tech post, the category should be either php or symfony!" + message: 'If this is a tech post, the category should be either php or symfony!' )] private $propertyExpression; @@ -299,7 +295,7 @@ public function setPropertyWithCompoundValidationRule(int $propertyWithCompoundV $this->propertyWithCompoundValidationRule = $propertyWithCompoundValidationRule; } - #[Assert\Count(min: "0", max: "10")] + #[Assert\Count(min: '0', max: '10')] public function setPropertyNotBlank(int $propertyNotBlank): void { $this->propertyNotBlank = $propertyNotBlank; diff --git a/Tests/Functional/Entity/SymfonyConstraintsWithValidationGroups.php b/Tests/Functional/Entity/SymfonyConstraintsWithValidationGroups.php index cf83b6cb3..e5afcfbfa 100644 --- a/Tests/Functional/Entity/SymfonyConstraintsWithValidationGroups.php +++ b/Tests/Functional/Entity/SymfonyConstraintsWithValidationGroups.php @@ -25,7 +25,9 @@ class SymfonyConstraintsWithValidationGroups * @var int * * @Groups("test") + * * @Assert\NotBlank(groups={"test"}) + * * @Assert\Range(min=1, max=100) */ public $property; @@ -41,6 +43,7 @@ class SymfonyConstraintsWithValidationGroups * @var array * * @OA\Property(type="array", @OA\Items(type="string")) + * * @Assert\Valid */ public $propertyArray; @@ -52,8 +55,8 @@ class SymfonyConstraintsWithValidationGroups * @var int */ #[Assert\Range(min: 1, max: 100)] - #[Assert\NotBlank(groups: ["test"])] - #[Groups("test")] + #[Assert\NotBlank(groups: ['test'])] + #[Groups('test')] public $property; /** diff --git a/Tests/Functional/Entity/User.php b/Tests/Functional/Entity/User.php index c9e9b42dc..0e4edec48 100644 --- a/Tests/Functional/Entity/User.php +++ b/Tests/Functional/Entity/User.php @@ -63,12 +63,14 @@ class User /** * @var float + * * @OA\Property(default = 0.0) */ private $money; /** * @var \DateTime + * * @OA\Property(property="creationDate") */ private $createdAt; @@ -309,4 +311,4 @@ public function setDateAsInterface(\DateTimeInterface $dateAsInterface) $this->dateAsInterface = $dateAsInterface; } } -} \ No newline at end of file +} diff --git a/Tests/Functional/Entity/VirtualProperty.php b/Tests/Functional/Entity/VirtualProperty.php index 52ab283ef..0f5dfe604 100644 --- a/Tests/Functional/Entity/VirtualProperty.php +++ b/Tests/Functional/Entity/VirtualProperty.php @@ -17,6 +17,7 @@ * Class VirtualProperty. * * @Serializer\ExclusionPolicy("all") + * * @Serializer\VirtualProperty( * "email", * exp="object.user.email", @@ -27,7 +28,9 @@ class VirtualProperty { /** * @var int + * * @Serializer\Type("integer") + * * @Serializer\Expose */ private $id; @@ -39,7 +42,9 @@ class VirtualProperty /** * @Serializer\Accessor(getter="getFoo", setter="setFoo") + * * @Serializer\Type("string") + * * @Serializer\Expose * * Ensures https://github.com/nelmio/NelmioApiDocBundle/issues/1708 is fixed. diff --git a/Tests/Functional/EntityExcluded/ApiPlatform2/Dummy.php b/Tests/Functional/EntityExcluded/ApiPlatform2/Dummy.php index 5b9ce094f..b8c9e6a27 100644 --- a/Tests/Functional/EntityExcluded/ApiPlatform2/Dummy.php +++ b/Tests/Functional/EntityExcluded/ApiPlatform2/Dummy.php @@ -38,6 +38,7 @@ class Dummy * @var string * * @Assert\NotBlank + * * @ApiProperty(iri="http://schema.org/name") */ private $name; diff --git a/Tests/Functional/EntityExcluded/Symfony7/SerializedNameEntity.php b/Tests/Functional/EntityExcluded/Symfony7/SerializedNameEntity.php index 6cf7d4f16..7046b2969 100644 --- a/Tests/Functional/EntityExcluded/Symfony7/SerializedNameEntity.php +++ b/Tests/Functional/EntityExcluded/Symfony7/SerializedNameEntity.php @@ -21,13 +21,13 @@ class SerializedNameEntity /** * @var string */ - #[SerializedName("notfoo")] + #[SerializedName('notfoo')] public $foo; /** * Tests serialized name feature. */ - #[SerializedName("notwhatyouthink")] + #[SerializedName('notwhatyouthink')] public function setBar(string $bar) { } diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php index 237f0790c..222dce79e 100644 --- a/Tests/Functional/TestKernel.php +++ b/Tests/Functional/TestKernel.php @@ -37,12 +37,11 @@ class TestKernel extends Kernel { - const USE_JMS = 1; - const USE_BAZINGA = 2; - const ERROR_ARRAY_ITEMS = 4; - const USE_VALIDATION_GROUPS = 8; - use MicroKernelTrait; + public const USE_JMS = 1; + public const USE_BAZINGA = 2; + public const ERROR_ARRAY_ITEMS = 4; + public const USE_VALIDATION_GROUPS = 8; private $flags; @@ -55,9 +54,6 @@ public function __construct(int $flags = 0) $this->flags = $flags; } - /** - * {@inheritdoc} - */ public function registerBundles(): iterable { $bundles = [ @@ -84,9 +80,6 @@ public function registerBundles(): iterable return $bundles; } - /** - * {@inheritdoc} - */ protected function configureRoutes($routes) { if (self::MAJOR_VERSION < 7) { @@ -132,9 +125,6 @@ private function import($routes, $resource, $prefix, $type) } } - /** - * {@inheritdoc} - */ protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) { $framework = [ @@ -166,7 +156,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load 'strict_variables' => '%kernel.debug%', 'exception_controller' => null, ]); - + if (self::MAJOR_VERSION < 7) { $c->loadFromExtension('sensio_framework_extra', [ 'router' => [ @@ -175,7 +165,6 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load ]); } - $c->loadFromExtension('api_platform', [ 'mapping' => ['paths' => [ !class_exists(ApiProperty::class) @@ -338,17 +327,11 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load $c->setDefinition('nelmio.test.jms.virtual_type.describer', $def); } - /** - * {@inheritdoc} - */ public function getCacheDir(): string { return parent::getCacheDir().'/'.$this->flags; } - /** - * {@inheritdoc} - */ public function getLogDir(): string { return parent::getLogDir().'/'.$this->flags; diff --git a/Tests/Functional/WebTestCase.php b/Tests/Functional/WebTestCase.php index 846c59a42..83f58bc91 100644 --- a/Tests/Functional/WebTestCase.php +++ b/Tests/Functional/WebTestCase.php @@ -14,7 +14,6 @@ use OpenApi\Annotations as OA; use OpenApi\Generator; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\KernelInterface; class WebTestCase extends BaseWebTestCase diff --git a/Tests/Model/ModelRegistryTest.php b/Tests/Model/ModelRegistryTest.php index 2b36455cf..59f559d7b 100644 --- a/Tests/Model/ModelRegistryTest.php +++ b/Tests/Model/ModelRegistryTest.php @@ -151,8 +151,6 @@ public function testNameCollisionsAreLoggedWithAlternativeNames() /** * @dataProvider getNameAlternatives - * - * @param $expected */ public function testNameAliasingForObjects(string $expected, $groups, array $alternativeNames) { diff --git a/Tests/ModelDescriber/Annotations/AnnotationReaderTest.php b/Tests/ModelDescriber/Annotations/AnnotationReaderTest.php index e9b42fe45..4aedd3798 100644 --- a/Tests/ModelDescriber/Annotations/AnnotationReaderTest.php +++ b/Tests/ModelDescriber/Annotations/AnnotationReaderTest.php @@ -27,6 +27,7 @@ class AnnotationReaderTest extends TestCase /** * @param object $entity + * * @dataProvider provideProperty */ public function testProperty($entity) diff --git a/Tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php b/Tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php index 4e155cd76..55026e6ce 100644 --- a/Tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php +++ b/Tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php @@ -41,6 +41,7 @@ public function testUpdatePropertyFix1283() $entity = new class() { /** * @Assert\NotBlank() + * * @Assert\Length(min = 1) */ private $property1; @@ -66,6 +67,7 @@ public function testUpdatePropertyFix1283() /** * @param object $entity + * * @dataProvider provideOptionalProperty */ public function testOptionalProperty($entity) @@ -93,6 +95,7 @@ public function provideOptionalProperty(): iterable yield 'Annotations' => [new class() { /** * @Assert\NotBlank(allowNull = true) + * * @Assert\Length(min = 1) */ private $property1; @@ -115,6 +118,7 @@ public function provideOptionalProperty(): iterable /** * @param object $entity + * * @dataProvider provideAssertChoiceResultsInNumericArray */ public function testAssertChoiceResultsInNumericArray($entity) @@ -141,6 +145,7 @@ public function provideAssertChoiceResultsInNumericArray(): iterable yield 'Annotations' => [new class() { /** * @Assert\Length(min = 1) + * * @Assert\Choice(choices=TEST_ASSERT_CHOICE_STATUSES) */ private $property1; @@ -157,6 +162,7 @@ public function provideAssertChoiceResultsInNumericArray(): iterable /** * @param object $entity + * * @dataProvider provideMultipleChoiceConstraintsApplyEnumToItems */ public function testMultipleChoiceConstraintsApplyEnumToItems($entity) @@ -192,7 +198,9 @@ public function provideMultipleChoiceConstraintsApplyEnumToItems(): iterable /** * @param object $entity + * * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1780 + * * @dataProvider provideLengthConstraintDoesNotSetMaxLengthIfMaxIsNotSet */ public function testLengthConstraintDoesNotSetMaxLengthIfMaxIsNotSet($entity) @@ -228,7 +236,9 @@ public function provideLengthConstraintDoesNotSetMaxLengthIfMaxIsNotSet(): itera /** * @param object $entity + * * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1780 + * * @dataProvider provideLengthConstraintDoesNotSetMinLengthIfMinIsNotSet */ public function testLengthConstraintDoesNotSetMinLengthIfMinIsNotSet($entity) @@ -297,7 +307,9 @@ public function testCompoundValidationRules() /** * @param object $entity + * * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1821 + * * @dataProvider provideCountConstraintDoesNotSetMinItemsIfMinIsNotSet */ public function testCountConstraintDoesNotSetMinItemsIfMinIsNotSet($entity) @@ -333,7 +345,9 @@ public function provideCountConstraintDoesNotSetMinItemsIfMinIsNotSet(): iterabl /** * @param object $entity + * * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1821 + * * @dataProvider provideCountConstraintDoesNotSetMaxItemsIfMaxIsNotSet */ public function testCountConstraintDoesNotSetMaxItemsIfMaxIsNotSet($entity) @@ -369,7 +383,9 @@ public function provideCountConstraintDoesNotSetMaxItemsIfMaxIsNotSet(): iterabl /** * @param object $entity + * * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1822 + * * @dataProvider provideRangeConstraintDoesNotSetMaximumIfMaxIsNotSet */ public function testRangeConstraintDoesNotSetMaximumIfMaxIsNotSet($entity) @@ -405,7 +421,9 @@ public function provideRangeConstraintDoesNotSetMaximumIfMaxIsNotSet(): iterable /** * @param object $entity + * * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1822 + * * @dataProvider provideRangeConstraintDoesNotSetMinimumIfMinIsNotSet */ public function testRangeConstraintDoesNotSetMinimumIfMinIsNotSet($entity) @@ -444,6 +462,7 @@ public function provideRangeConstraintDoesNotSetMinimumIfMinIsNotSet(): iterable * group when `group={"someGroup"}` is not set. * * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1857 + * * @dataProvider provideRangeConstraintDoesNotSetMinimumIfMinIsNotSet */ public function testReaderWithValidationGroupsEnabledChecksForDefaultGroupWhenNoSerializationGroupsArePassed($entity) @@ -464,6 +483,7 @@ public function testReaderWithValidationGroupsEnabledChecksForDefaultGroupWhenNo /** * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1857 + * * @dataProvider provideConstraintsWithGroups */ public function testReaderWithValidationGroupsEnabledDoesNotReadAnnotationsWithoutDefaultGroupIfNoGroupsArePassed($entity) @@ -487,6 +507,7 @@ public function testReaderWithValidationGroupsEnabledDoesNotReadAnnotationsWitho /** * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1857 + * * @dataProvider provideConstraintsWithGroups */ public function testReaderWithValidationGroupsEnabledReadsOnlyConstraintsWithGroupsProvided($entity) @@ -511,6 +532,7 @@ public function testReaderWithValidationGroupsEnabledReadsOnlyConstraintsWithGro /** * @group https://github.com/nelmio/NelmioApiDocBundle/issues/1857 + * * @dataProvider provideConstraintsWithGroups */ public function testReaderWithValidationGroupsEnabledCanReadFromMultipleValidationGroups($entity) @@ -538,6 +560,7 @@ public function provideConstraintsWithGroups(): iterable yield 'Annotations' => [new class() { /** * @Assert\NotBlank() + * * @Assert\Range(min=1, groups={"other"}) */ private $property1; diff --git a/Tests/ModelDescriber/ApplyOpenApiDiscriminatorTraitTest.php b/Tests/ModelDescriber/ApplyOpenApiDiscriminatorTraitTest.php index 49271dffb..20fb7582b 100644 --- a/Tests/ModelDescriber/ApplyOpenApiDiscriminatorTraitTest.php +++ b/Tests/ModelDescriber/ApplyOpenApiDiscriminatorTraitTest.php @@ -24,8 +24,8 @@ class ApplyOpenApiDiscriminatorTraitTest extends TestCase { use ApplyOpenApiDiscriminatorTrait; - const GROUPS = ['test']; - const OPTIONS = ['test' => 123]; + public const GROUPS = ['test']; + public const OPTIONS = ['test' => 123]; private $schema; diff --git a/Tests/Render/RenderOpenApiTest.php b/Tests/Render/RenderOpenApiTest.php index 514b0c822..c8d6cc164 100644 --- a/Tests/Render/RenderOpenApiTest.php +++ b/Tests/Render/RenderOpenApiTest.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\Tests\Render; -use InvalidArgumentException; use Nelmio\ApiDocBundle\Render\OpenApiRenderer; use Nelmio\ApiDocBundle\Render\RenderOpenApi; use OpenApi\Annotations\OpenApi; @@ -35,14 +34,14 @@ public function testRender() public function testUnknownFormat() { $availableOpenApiRenderers = []; - $this->expectExceptionObject(new InvalidArgumentException(sprintf('Format "%s" is not supported.', $this->format))); + $this->expectExceptionObject(new \InvalidArgumentException(sprintf('Format "%s" is not supported.', $this->format))); $this->renderOpenApi(...$availableOpenApiRenderers); } public function testUnknownArea() { $this->hasArea = false; - $this->expectExceptionObject(new InvalidArgumentException(sprintf('Area "%s" is not supported.', $this->area))); + $this->expectExceptionObject(new \InvalidArgumentException(sprintf('Area "%s" is not supported.', $this->area))); $this->renderOpenApi(); } diff --git a/Tests/Routing/FilteredRouteCollectionBuilderTest.php b/Tests/Routing/FilteredRouteCollectionBuilderTest.php index 32cc91a98..d4f63b593 100644 --- a/Tests/Routing/FilteredRouteCollectionBuilderTest.php +++ b/Tests/Routing/FilteredRouteCollectionBuilderTest.php @@ -72,6 +72,7 @@ public function testFilter() /** * @group legacy + * * @expectedDeprecation Passing an indexed array with a collection of path patterns as argument 1 for `Nelmio\ApiDocBundle\Routing\FilteredRouteCollectionBuilder::__construct()` is deprecated since 3.2.0, expected structure is an array containing parameterized options. */ public function testFilterWithDeprecatedArgument() @@ -186,6 +187,7 @@ public function getMatchingRoutes(): iterable /** * @group test + * * @dataProvider getMatchingRoutesWithAnnotation */ public function testMatchingRoutesWithAnnotation(string $name, Route $route, array $options = []) diff --git a/Tests/Util/ControllerReflectorTest.php b/Tests/Util/ControllerReflectorTest.php index d44b0dbde..50a6408ff 100644 --- a/Tests/Util/ControllerReflectorTest.php +++ b/Tests/Util/ControllerReflectorTest.php @@ -5,7 +5,6 @@ use Nelmio\ApiDocBundle\Tests\Functional\Controller\BazingaController; use Nelmio\ApiDocBundle\Util\ControllerReflector; use PHPUnit\Framework\TestCase; -use ReflectionMethod; use Symfony\Component\DependencyInjection\Container; class ControllerReflectorTest extends TestCase @@ -14,11 +13,11 @@ public function testGetReflectionMethod(): void { $controllerReflector = new ControllerReflector(new Container()); $this->assertEquals( - ReflectionMethod::class, + \ReflectionMethod::class, get_class($controllerReflector->getReflectionMethod([BazingaController::class, 'userAction'])) ); $this->assertEquals( - ReflectionMethod::class, + \ReflectionMethod::class, get_class($controllerReflector->getReflectionMethod(BazingaController::class.'::userAction')) ); $this->assertNull(