Skip to content

Commit

Permalink
feat: [5.x] drop symfony 5.4 (#2424)
Browse files Browse the repository at this point in the history
## Description

Drops support for Symfony 5.4

## What type of PR is this? (check all applicable)
- [ ] Bug Fix
- [x] Feature
- [ ] Refactor
- [ ] Deprecation
- [ ] Breaking Change
- [ ] Documentation Update
- [ ] CI

## Checklist
- [ ] I have made corresponding changes to the documentation (`docs/`)
- [ ] I have made corresponding changes to the changelog
(`CHANGELOG.md`)
  • Loading branch information
DjordyKoert authored Jan 18, 2025
1 parent eb8cc49 commit bbf11aa
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 320 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,8 @@ jobs:
matrix:
include:
- php-version: 8.1
symfony-require: "5.4"
symfony-require: "6.4"
composer-flags: "--prefer-lowest"
- php-version: 8.1
symfony-require: "5.4"
- php-version: 8.2
symfony-require: "5.4"
- php-version: 8.3
symfony-require: "5.4"
- php-version: 8.4
symfony-require: "5.4"
- php-version: 8.1
symfony-require: "6.4"
- php-version: 8.2
Expand Down
4 changes: 4 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## BC BREAK: Bumped minimum PHP version to 8.1

## Bumped minimum Symfony version to 6.4

## Dropped support for Api Platform 2

## BC BREAK: Removed support for annotations
Upgrade to PHP 8.1 attributes.

Expand Down
54 changes: 27 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,45 @@
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/container": "^1.0 || ^2.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"symfony/config": "^5.4 || ^6.4 || ^7.1",
"symfony/console": "^5.4 || ^6.4 || ^7.1",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.1",
"symfony/config": "^6.4 || ^7.1",
"symfony/console": "^6.4 || ^7.1",
"symfony/dependency-injection": "^6.4 || ^7.1",
"symfony/deprecation-contracts": "^2.1 || ^3",
"symfony/framework-bundle": "^5.4.24 || ^6.4 || ^7.1",
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.1",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.1",
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.1",
"symfony/property-info": "^5.4.10 || ^6.4 || ^7.1",
"symfony/routing": "^5.4 || ^6.4 || ^7.1",
"symfony/framework-bundle": "^6.4 || ^7.1",
"symfony/http-foundation": "^6.4 || ^7.1",
"symfony/http-kernel": "^6.4 || ^7.1",
"symfony/options-resolver": "^6.4 || ^7.1",
"symfony/property-info": "^6.4 || ^7.1",
"symfony/routing": "^6.4 || ^7.1",
"zircote/swagger-php": "^4.11.1 || ^5.0"
},
"require-dev": {
"api-platform/core": "^2.7.0 || ^3",
"api-platform/core": "^3.2",
"friendsofphp/php-cs-fixer": "^3.52",
"friendsofsymfony/rest-bundle": "^3.2.0",
"jms/serializer": "^3.0",
"jms/serializer-bundle": "^5.2",
"jms/serializer": "^3.32",
"jms/serializer-bundle": "^5.5",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^10.5",
"symfony/asset": "^5.4 || ^6.4 || ^7.1",
"symfony/browser-kit": "^5.4 || ^6.4 || ^7.1",
"symfony/cache": "^5.4 || ^6.4 || ^7.1",
"symfony/dom-crawler": "^5.4 || ^6.4 || ^7.1",
"symfony/expression-language": "^5.4 || ^6.4 || ^7.1",
"symfony/form": "^5.4 || ^6.4 || ^7.1",
"symfony/asset": "^6.4 || ^7.1",
"symfony/browser-kit": "^6.4 || ^7.1",
"symfony/cache": "^6.4 || ^7.1",
"symfony/dom-crawler": "^6.4 || ^7.1",
"symfony/expression-language": "^6.4 || ^7.1",
"symfony/form": "^6.4 || ^7.1",
"symfony/phpunit-bridge": "^6.4",
"symfony/property-access": "^5.4 || ^6.4 || ^7.1",
"symfony/security-csrf": "^5.4 || ^6.4 || ^7.1",
"symfony/serializer": "^5.4 || ^6.4 || ^7.1",
"symfony/stopwatch": "^5.4 || ^6.4 || ^7.1",
"symfony/templating": "^5.4 || ^6.4 || ^7.1",
"symfony/twig-bundle": "^5.4 || ^6.4 || ^7.1",
"symfony/uid": "^5.4 || ^6.4 || ^7.1",
"symfony/validator": "^5.4 || ^6.4 || ^7.1",
"willdurand/hateoas-bundle": "^2.7@beta",
"symfony/property-access": "^6.4 || ^7.1",
"symfony/security-csrf": "^6.4 || ^7.1",
"symfony/serializer": "^6.4 || ^7.1",
"symfony/stopwatch": "^6.4 || ^7.1",
"symfony/templating": "^6.4 || ^7.1",
"symfony/twig-bundle": "^6.4 || ^7.1",
"symfony/uid": "^6.4 || ^7.1",
"symfony/validator": "^6.4 || ^7.1",
"willdurand/hateoas-bundle": "^2.7",
"willdurand/negotiation": "^3.0"
},
"conflict": {
Expand Down
3 changes: 1 addition & 2 deletions src/Describer/ApiPlatformDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Nelmio\ApiDocBundle\Describer;

use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer;
use ApiPlatform\Documentation\DocumentationInterface;
use ApiPlatform\OpenApi\OpenApi;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
Expand All @@ -32,7 +31,7 @@ public function __construct(object $documentation, NormalizerInterface $normaliz
$documentation = (array) $normalizer->normalize(
$documentation,
null,
class_exists(DocumentationNormalizer::class) ? [DocumentationNormalizer::SPEC_VERSION => 3] : []
[]
);

// TODO: remove this
Expand Down
5 changes: 0 additions & 5 deletions src/PropertyDescriber/PropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ private function getHash(array $types): string
private function getPropertyDescriber(array $types, array $context): ?PropertyDescriberInterface
{
foreach ($this->propertyDescribers as $propertyDescriber) {
/* BC layer for Symfony < 6.3 @see https://symfony.com/doc/6.3/service_container/tags.html#reference-tagged-services */
if ($propertyDescriber instanceof self) {
continue;
}

// Prevent infinite recursion
if (\array_key_exists($this->getHash($types), $this->called)) {
if (\in_array($propertyDescriber, $this->called[$this->getHash($types)], true)) {
Expand Down
120 changes: 59 additions & 61 deletions tests/Functional/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,10 @@ public function testControllers(?array $controller, ?string $fixtureName = null,

public static function provideAttributeTestCases(): \Generator
{
$type = Kernel::MAJOR_VERSION === 5 ? 'annotation' : 'attribute';

yield 'Promoted properties defaults attributes' => [
[
'name' => 'PromotedPropertiesController81',
'type' => $type,
'type' => 'attribute',
],
'PromotedPropertiesDefaults',
[],
Expand All @@ -94,78 +92,78 @@ public static function provideAttributeTestCases(): \Generator
yield 'JMS model opt out' => [
[
'name' => 'JmsOptOutController',
'type' => $type,
'type' => 'attribute',
],
'JmsOptOutController',
[new JMSSerializerBundle()],
[__DIR__.'/Configs/JMS.yaml'],
];

if (version_compare(Kernel::VERSION, '6.3.0', '>=')) {
yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2209' => [
[
'name' => 'Controller2209',
'type' => $type,
],
];
yield 'MapQueryString' => [
[
'name' => 'MapQueryStringController',
'type' => $type,
null,
[],
[__DIR__.'/Configs/EnableSerializer.yaml'],
],
];
yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2191' => [
[
'name' => 'MapQueryStringController',
'type' => $type,
],
'MapQueryStringCleanupComponents',
[],
[__DIR__.'/Configs/CleanUnusedComponentsProcessor.yaml', __DIR__.'/Configs/EnableSerializer.yaml'],
];

yield 'operationId must always be generated' => [
[
'name' => 'OperationIdController',
'type' => $type,
],
];

yield 'Symfony 6.3 MapQueryParameter attribute' => [
[
'name' => 'MapQueryParameterController',
'type' => $type,
],
];
yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2209' => [
[
'name' => 'Controller2209',
'type' => 'attribute',
],
];

yield 'Symfony 6.3 MapRequestPayload attribute' => [
[
'name' => 'MapRequestPayloadController',
'type' => $type,
],
yield 'MapQueryString' => [
[
'name' => 'MapQueryStringController',
'type' => 'attribute',
null,
[],
[__DIR__.'/Configs/EnableSerializer.yaml'],
];
],
];

yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2191' => [
[
'name' => 'MapQueryStringController',
'type' => 'attribute',
],
'MapQueryStringCleanupComponents',
[],
[__DIR__.'/Configs/CleanUnusedComponentsProcessor.yaml', __DIR__.'/Configs/EnableSerializer.yaml'],
];

yield 'operationId must always be generated' => [
[
'name' => 'OperationIdController',
'type' => 'attribute',
],
];

yield 'Symfony 6.3 MapQueryParameter attribute' => [
[
'name' => 'MapQueryParameterController',
'type' => 'attribute',
],
];

yield 'Symfony 6.3 MapRequestPayload attribute' => [
[
'name' => 'MapRequestPayloadController',
'type' => 'attribute',
],
null,
[],
[__DIR__.'/Configs/EnableSerializer.yaml'],
];

yield 'Create top level Tag from Tag attribute' => [
yield 'Create top level Tag from Tag attribute' => [
[
'name' => 'OpenApiTagController',
'type' => 'attribute',
],
];

if (property_exists(MapRequestPayload::class, 'type')) {
yield 'Symfony 7.1 MapRequestPayload array type' => [
[
'name' => 'OpenApiTagController',
'type' => $type,
'name' => 'MapRequestPayloadArray',
'type' => 'attribute',
],
];

if (property_exists(MapRequestPayload::class, 'type')) {
yield 'Symfony 7.1 MapRequestPayload array type' => [
[
'name' => 'MapRequestPayloadArray',
'type' => $type,
],
];
}
}
}

Expand Down
12 changes: 2 additions & 10 deletions tests/Functional/Entity/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@

namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;

use ApiPlatform\Core\Annotation\ApiProperty;
use Nelmio\ApiDocBundle\Tests\Functional\EntityExcluded;

// BC Api-Platform < 3.x
if (class_exists(ApiProperty::class)) {
class Dummy extends EntityExcluded\ApiPlatform2\Dummy
{
}
} else {
class Dummy extends EntityExcluded\ApiPlatform3\Dummy
{
}
class Dummy extends EntityExcluded\ApiPlatform3\Dummy
{
}
35 changes: 13 additions & 22 deletions tests/Functional/Entity/RangeInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;

use Symfony\Component\HttpKernel\Kernel;

trait RangeIntegerTrait
{
/**
Expand All @@ -38,24 +36,17 @@ trait RangeIntegerTrait
public $nullableRangeInt;
}

if (version_compare(Kernel::VERSION, '6.1', '>=')) {
class RangeInteger
{
use RangeIntegerTrait;

/**
* @var positive-int
*/
public $positiveInt;

/**
* @var negative-int
*/
public $negativeInt;
}
} else {
class RangeInteger
{
use RangeIntegerTrait;
}
class RangeInteger
{
use RangeIntegerTrait;

/**
* @var positive-int
*/
public $positiveInt;

/**
* @var negative-int
*/
public $negativeInt;
}
Loading

0 comments on commit bbf11aa

Please sign in to comment.