Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump Symfony minimum to 6.4 #2335

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,12 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: 7.4
- php-version: 8.1
composer-flags: "--prefer-lowest"
doctrine-annotations: true
- php-version: 7.4
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 8.0
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 8.1
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 8.3
symfony-require: "5.4.*"
composer-flags: "--prefer-lowest"
symfony-require: "6.4.*"
doctrine-annotations: true
- php-version: 8.1
symfony-require: "6.4.*"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

Unreleased
----------
* Bumped minimum Symfony version from 5.4 to 6.4.

4.26.0
-----
* Add ability to configure UI through configuration
Expand Down
55 changes: 28 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.1",
"ext-json": "*",
"phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0",
"phpdocumentor/type-resolver": "^1.8.2",
"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.0",
"symfony/console": "^5.4 || ^6.4 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
"symfony/config": "^6.4 || ^7.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/deprecation-contracts": "^2.1 || ^3",
"symfony/framework-bundle": "^5.4.24 || ^6.4 || ^7.0",
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
"symfony/property-info": "^5.4.10 || ^6.4 || ^7.0",
"symfony/routing": "^5.4 || ^6.4 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/http-foundation": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0",
"symfony/options-resolver": "^6.4 || ^7.0",
"symfony/property-info": "^6.4 || ^7.0",
"symfony/routing": "^6.4 || ^7.0",
"zircote/swagger-php": "^4.6.1"
},
"require-dev": {
Expand All @@ -36,32 +36,33 @@
"doctrine/annotations": "^2.0",
"friendsofphp/php-cs-fixer": "^3.52",
"friendsofsymfony/rest-bundle": "^2.8 || ^3.0",
"jms/serializer": "^1.14 || ^3.0",
"jms/serializer-bundle": "^2.3 || ^3.0 || ^4.0 || ^5.0",
"jms/serializer": "^3.0",
"jms/serializer-bundle": "^5.0",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^9.6 || ^10.5",
"symfony/asset": "^5.4 || ^6.4 || ^7.0",
"symfony/browser-kit": "^5.4 || ^6.4 || ^7.0",
"symfony/cache": "^5.4 || ^6.4 || ^7.0",
"symfony/dom-crawler": "^5.4 || ^6.4 || ^7.0",
"symfony/expression-language": "^5.4 || ^6.4 || ^7.0",
"symfony/form": "^5.4 || ^6.4 || ^7.0",
"symfony/asset": "^6.4 || ^7.0",
"symfony/browser-kit": "^6.4 || ^7.0",
"symfony/cache": "^6.4 || ^7.0",
"symfony/dom-crawler": "^6.4 || ^7.0",
"symfony/expression-language": "^6.4 || ^7.0",
"symfony/form": "^6.4 || ^7.0",
"symfony/phpunit-bridge": "^6.4",
"symfony/property-access": "^5.4 || ^6.4 || ^7.0",
"symfony/security-csrf": "^5.4 || ^6.4 || ^7.0",
"symfony/serializer": "^5.4 || ^6.4 || ^7.0",
"symfony/stopwatch": "^5.4 || ^6.4 || ^7.0",
"symfony/templating": "^5.4 || ^6.4 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/uid": "^5.4 || ^6.4 || ^7.0",
"symfony/validator": "^5.4 || ^6.4 || ^7.0",
"symfony/property-access": "^6.4 || ^7.0",
"symfony/security-csrf": "^6.4 || ^7.0",
"symfony/serializer": "^6.4 || ^7.0",
"symfony/stopwatch": "^6.4 || ^7.0",
"symfony/templating": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"symfony/uid": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"willdurand/hateoas-bundle": "^1.0 || ^2.0"
},
"conflict": {
"zircote/swagger-php": "4.8.7"
"zircote/swagger-php": "4.8.7",
"willdurand/negotiation": "<3.0"
},
"suggest": {
"api-platform/core": "For using an API oriented framework.",
Expand Down
4 changes: 1 addition & 3 deletions config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
<!-- Swagger Spec Generator -->
<service id="nelmio_api_doc.generator" alias="nelmio_api_doc.generator.default" public="true" />

<service id="nelmio_api_doc.controller_reflector" class="Nelmio\ApiDocBundle\Util\ControllerReflector" public="false">
<argument type="service" id="service_container" />
</service>
<service id="nelmio_api_doc.controller_reflector" class="Nelmio\ApiDocBundle\Util\ControllerReflector" public="false" />

<!-- Describers -->
<service id="nelmio_api_doc.describers.config" class="Nelmio\ApiDocBundle\Describer\ExternalDocDescriber" public="false">
Expand Down
12 changes: 0 additions & 12 deletions src/DependencyInjection/NelmioApiDocExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,6 @@ public function load(array $configs, ContainerBuilder $container): void

// Import the base configuration
$container->getDefinition('nelmio_api_doc.describers.config')->replaceArgument(0, $config['documentation']);

// Compatibility Symfony
$controllerNameConverter = null;
if ($container->hasDefinition('.legacy_controller_name_converter')) { // 4.4
$controllerNameConverter = $container->getDefinition('.legacy_controller_name_converter');
} elseif ($container->hasDefinition('controller_name_converter')) { // < 4.4
$controllerNameConverter = $container->getDefinition('controller_name_converter');
}

if (null !== $controllerNameConverter) {
$container->getDefinition('nelmio_api_doc.controller_reflector')->setArgument(1, $controllerNameConverter);
}
}

/**
Expand Down
10 changes: 0 additions & 10 deletions src/Form/Extension/DocumentationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ public function configureOptions(OptionsResolver $resolver): void
->setAllowedTypes('documentation', ['array', 'bool']);
}

/**
* @deprecated since Symfony 4.2, use getExtendedTypes() instead.
*
* @return string
*/
public function getExtendedType()
{
return self::getExtendedTypes()[0];
}

public static function getExtendedTypes(): iterable
{
return [FormType::class];
Expand Down
4 changes: 0 additions & 4 deletions src/ModelDescriber/FormModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use OpenApi\Analysis;
use OpenApi\Annotations as OA;
use OpenApi\Generator;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormConfigInterface;
use Symfony\Component\Form\FormFactoryInterface;
Expand Down Expand Up @@ -74,9 +73,6 @@ public function __construct(

public function describe(Model $model, OA\Schema $schema): void
{
if (method_exists(AbstractType::class, 'setDefaultOptions')) {
throw new \LogicException('symfony/form < 3.0 is not supported, please upgrade to an higher version to use a form as a model.');
}
if (null === $this->formFactory) {
throw new \LogicException('You need to enable forms in your application to use a form as a model.');
}
Expand Down
5 changes: 0 additions & 5 deletions src/PropertyDescriber/PropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ private function getHash(array $types): string
private function getPropertyDescriber(array $types): ?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 (key_exists($this->getHash($types), $this->called)) {
if (in_array($propertyDescriber, $this->called[$this->getHash($types)], true)) {
Expand Down
12 changes: 0 additions & 12 deletions src/Util/ControllerReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,16 @@

namespace Nelmio\ApiDocBundle\Util;

use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* @internal
*/
class ControllerReflector
{
private ContainerInterface $container;
/**
* @var array<string, array{string, string}|null>
*/
private array $controllers = [];

public function __construct(ContainerInterface $container)
{
$this->container = $container;
}

/**
* Returns the ReflectionMethod for the given controller string.
*
Expand Down Expand Up @@ -71,10 +63,6 @@ private function getClassAndMethod(string $controller): ?array
$class = $matches[1];
$method = $matches[2];

if (!class_exists($class) && $this->container->has($class)) {
$class = get_class($this->container->get($class));
}

return $this->controllers[$controller] = [$class, $method];
}

Expand Down
25 changes: 25 additions & 0 deletions tests/ComposerHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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\Tests;

final class ComposerHelper
{
public static function compareVersion(string $package, string $version): ?int
{
return version_compare(\Composer\InstalledVersions::getPrettyVersion($package), $version);
}

public static function isPackageInstalled(string $package): bool
{
return \Composer\InstalledVersions::isInstalled($package);
}
}
3 changes: 1 addition & 2 deletions tests/Describer/RouteDescriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use OpenApi\Annotations\OpenApi;
use OpenApi\Context;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

Expand Down Expand Up @@ -45,7 +44,7 @@ protected function setUp(): void
$this->routes = new RouteCollection();
$this->describer = new RouteDescriber(
$this->routes,
new ControllerReflector(new Container()),
new ControllerReflector(),
[$this->routeDescriber]
);
}
Expand Down
8 changes: 0 additions & 8 deletions tests/Functional/Configs/AlternativeNamesPHP80Entities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ nelmio_api_doc:
type: Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithPromotedPropertiesWithDefaults80
- alias: EntityWithAlternateType
type: Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithAlternateType80

# Clean unused components from the OpenAPI schema.
services:
OpenApi\Processors\CleanUnusedComponents:
tags:
- { name: 'nelmio_api_doc.swagger.processor', priority: -100 }
calls:
- setEnabled: [ true ]
8 changes: 0 additions & 8 deletions tests/Functional/Configs/AlternativeNamesPHP81Entities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ nelmio_api_doc:
type: Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithPromotedPropertiesWithDefaults81
- alias: EntityWithAlternateType
type: Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithAlternateType81

# Clean unused components from the OpenAPI schema.
services:
OpenApi\Processors\CleanUnusedComponents:
tags:
- { name: 'nelmio_api_doc.swagger.processor', priority: -100 }
calls:
- setEnabled: [ true ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
OpenApi\Processors\CleanUnusedComponents:
tags:
- { name: 'nelmio_api_doc.swagger.processor', priority: -100 }
Loading