Skip to content

Commit

Permalink
Remove support for Symfony 5 (#1849)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored Jan 14, 2025
1 parent dbc56be commit 24411a4
Show file tree
Hide file tree
Showing 70 changed files with 286 additions and 663 deletions.
28 changes: 6 additions & 22 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "highest"
stability:
Expand All @@ -37,32 +36,21 @@ jobs:
# Tests the lowest set of dependencies
- dependencies: "lowest"
stability: "stable"
php-version: "7.4"
php-version: "8.1"

# Test LTS
- symfony-require: "5.4.*"
- symfony-require: "6.4.*"
dependencies: "highest"
php-version: "8.0"

# Test last supported minor version
- symfony-require: "6.*"
dependencies: "highest"
php-version: "8.3"
php-version: "8.4"

# DBAL only without ORM
- php-version: "8.3"
- php-version: "8.4"
dependencies: "highest"
stability: "stable"
remove-orm: true

# DBAL 4
- php-version: "8.3"
dependencies: "highest"
stability: "dev"
remove-orm: true

# Bleeding edge
- php-version: "8.3"
- php-version: "8.4"
dependencies: "highest"
stability: "dev"

Expand All @@ -81,10 +69,6 @@ jobs:
extensions: "pdo_sqlite"
tools: "flex"

- name: "Require symfony/messenger"
run: "composer require --dev symfony/messenger --no-update"
if: "${{ startsWith(matrix.symfony-require, '5.') }}"

- name: "Enforce using stable dependencies"
run: "composer config minimum-stability stable"
if: "${{ matrix.stability == 'stable' }}"
Expand Down
47 changes: 24 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@
],
"homepage": "https://www.doctrine-project.org",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"doctrine/dbal": "^3.7.0 || ^4.0",
"doctrine/persistence": "^2.2 || ^3",
"doctrine/sql-formatter": "^1.0.1",
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/cache": "^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/doctrine-bridge": "^5.4.46 || ~6.3.12 || ^6.4.3 || ^7.0.3",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/polyfill-php80": "^1.15",
"symfony/service-contracts": "^1.1.1 || ^2.0 || ^3"
"symfony/doctrine-bridge": "^6.4.3 || ^7.0.3",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/service-contracts": "^2.5 || ^3"
},
"require-dev": {
"doctrine/annotations": "^1 || ^2",
Expand All @@ -53,26 +52,28 @@
"phpstan/phpstan": "2.1.1",
"phpstan/phpstan-phpunit": "2.0.3",
"phpstan/phpstan-strict-rules": "^2",
"phpunit/phpunit": "^9.5.26",
"phpunit/phpunit": "^9.6.22",
"psr/log": "^1.1.4 || ^2.0 || ^3.0",
"symfony/phpunit-bridge": "^6.1 || ^7.0",
"symfony/property-info": "^5.4 || ^6.0 || ^7.0",
"symfony/proxy-manager-bridge": "^5.4 || ^6.0",
"symfony/security-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0",
"symfony/string": "^5.4 || ^6.0 || ^7.0",
"symfony/twig-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
"symfony/var-exporter": "^5.4 || ^6.2 || ^7.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
"twig/twig": "^1.34 || ^2.12 || ^3.0"
"symfony/doctrine-messenger": "^6.4 || ^7.0",
"symfony/messenger": "^6.4 || ^7.0",
"symfony/phpunit-bridge": "^7.2",
"symfony/property-info": "^6.4 || ^7.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/stopwatch": "^6.4 || ^7.0",
"symfony/string": "^6.4 || ^7.0",
"symfony/twig-bridge": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"symfony/var-exporter": "^6.4.1 || ^7.0.1",
"symfony/web-profiler-bundle": "^6.4 || ^7.0",
"symfony/yaml": "^6.4 || ^7.0",
"twig/twig": "^2.13 || ^3.0.4"
},
"conflict": {
"doctrine/annotations": ">=3.0",
"doctrine/cache": "< 1.11",
"doctrine/orm": "<2.17 || >=4.0",
"twig/twig": "<1.34 || >=2.0 <2.4"
"symfony/var-exporter": "< 6.4.1 || 7.0.0",
"twig/twig": "<2.13 || >=3.0 <3.0.4"
},
"suggest": {
"ext-pdo": "*",
Expand Down
4 changes: 0 additions & 4 deletions config/messenger.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
<tag name="messenger.transport_factory" />
</service>

<service id="doctrine.orm.messenger.doctrine_schema_subscriber" class="Symfony\Bridge\Doctrine\SchemaListener\MessengerTransportDoctrineSchemaSubscriber">
<argument type="tagged_iterator" tag="messenger.receiver" />
<tag name="doctrine.event_subscriber" />
</service>
<service id="doctrine.orm.messenger.doctrine_schema_listener" class="Symfony\Bridge\Doctrine\SchemaListener\MessengerTransportDoctrineSchemaListener">
<argument type="tagged_iterator" tag="messenger.receiver" />
<tag name="doctrine.event_listener" event="postGenerateSchema" />
Expand Down
12 changes: 0 additions & 12 deletions config/orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,10 @@

<!-- listeners -->
<service id="doctrine.orm.listeners.resolve_target_entity" class="%doctrine.orm.listeners.resolve_target_entity.class%" public="false" />
<service id="doctrine.orm.listeners.doctrine_dbal_cache_adapter_schema_subscriber" class="Symfony\Bridge\Doctrine\SchemaListener\DoctrineDbalCacheAdapterSchemaSubscriber">
<argument type="collection" /> <!-- DoctrineDbalAdapter instances -->
<tag name="doctrine.event_subscriber" />
</service>
<service id="doctrine.orm.listeners.doctrine_dbal_cache_adapter_schema_listener" class="Symfony\Bridge\Doctrine\SchemaListener\DoctrineDbalCacheAdapterSchemaListener">
<argument type="collection" /> <!-- DoctrineDbalAdapter instances -->
<tag name="doctrine.event_listener" event="postGenerateSchema" />
</service>
<service id="doctrine.orm.listeners.pdo_cache_adapter_doctrine_schema_subscriber" class="Symfony\Bridge\Doctrine\SchemaListener\PdoCacheAdapterDoctrineSchemaSubscriber">
<argument type="collection" /> <!-- PdoAdapter instances -->
<tag name="doctrine.event_subscriber" />
</service>
<service id="doctrine.orm.listeners.doctrine_token_provider_schema_subscriber" class="Symfony\Bridge\Doctrine\SchemaListener\RememberMeTokenProviderDoctrineSchemaSubscriber">
<argument type="tagged_iterator" tag="security.remember_me_handler" />
<tag name="doctrine.event_subscriber" />
</service>
<service id="doctrine.orm.listeners.doctrine_token_provider_schema_listener" class="Symfony\Bridge\Doctrine\SchemaListener\RememberMeTokenProviderDoctrineSchemaListener">
<argument type="tagged_iterator" tag="security.remember_me_handler" />
<tag name="doctrine.event_listener" event="postGenerateSchema" />
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<config name="php_version" value="70400"/>
<config name="php_version" value="80100"/>

<file>src</file>
<file>tests</file>
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/AsDoctrineListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class AsDoctrineListener
{
public function __construct(
public string $event,
public ?int $priority = null,
public ?string $connection = null,
public int|null $priority = null,
public string|null $connection = null,
) {
}
}
12 changes: 6 additions & 6 deletions src/Attribute/AsEntityListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
class AsEntityListener
{
public function __construct(
public ?string $event = null,
public ?string $method = null,
public ?bool $lazy = null,
public ?string $entityManager = null,
public ?string $entity = null,
public ?int $priority = null,
public string|null $event = null,
public string|null $method = null,
public bool|null $lazy = null,
public string|null $entityManager = null,
public string|null $entity = null,
public int|null $priority = null,
) {
}
}
2 changes: 1 addition & 1 deletion src/Attribute/AsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AsMiddleware
/** @param string[] $connections */
public function __construct(
public array $connections = [],
public ?int $priority = null,
public int|null $priority = null,
) {
}
}
14 changes: 5 additions & 9 deletions src/CacheWarmer/DoctrineMetadataCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
/** @final since 2.11 */
class DoctrineMetadataCacheWarmer extends AbstractPhpFileCacheWarmer
{
private EntityManagerInterface $entityManager;
private string $phpArrayFile;

public function __construct(EntityManagerInterface $entityManager, string $phpArrayFile)
{
$this->entityManager = $entityManager;
$this->phpArrayFile = $phpArrayFile;

public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly string $phpArrayFile,
) {
parent::__construct($phpArrayFile);
}

Expand All @@ -32,7 +28,7 @@ public function isOptional(): bool
return false;
}

protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, ?string $buildDir = null): bool
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, string|null $buildDir = null): bool
{
// cache already warmed up, no needs to do it again
if (is_file($this->phpArrayFile)) {
Expand Down
9 changes: 3 additions & 6 deletions src/Command/DoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
*/
abstract class DoctrineCommand extends Command
{
private ManagerRegistry $doctrine;

public function __construct(ManagerRegistry $doctrine)
{
public function __construct(
private readonly ManagerRegistry $doctrine,
) {
parent::__construct();

$this->doctrine = $doctrine;
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/Command/ImportMappingDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@
*/
class ImportMappingDoctrineCommand extends DoctrineCommand
{
/** @var string[] */
private array $bundles;

/** @param string[] $bundles */
public function __construct(ManagerRegistry $doctrine, array $bundles)
{
public function __construct(
ManagerRegistry $doctrine,
private readonly array $bundles,
) {
parent::__construct($doctrine);

$this->bundles = $bundles;
}

protected function configure(): void
Expand Down
9 changes: 3 additions & 6 deletions src/Command/Proxy/OrmProxyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
*/
trait OrmProxyCommand
{
private ?EntityManagerProvider $entityManagerProvider;

public function __construct(?EntityManagerProvider $entityManagerProvider = null)
{
public function __construct(
private readonly EntityManagerProvider|null $entityManagerProvider = null,
) {
parent::__construct($entityManagerProvider);

$this->entityManagerProvider = $entityManagerProvider;

trigger_deprecation(
'doctrine/doctrine-bundle',
'2.8',
Expand Down
16 changes: 7 additions & 9 deletions src/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ class ConnectionFactory
'sqlite3' => 'pdo_sqlite',
];

/** @var mixed[][] */
private array $typesConfig = [];

private DsnParser $dsnParser;
private readonly DsnParser $dsnParser;

private bool $initialized = false;

/** @param mixed[][] $typesConfig */
public function __construct(array $typesConfig, ?DsnParser $dsnParser = null)
{
$this->typesConfig = $typesConfig;
$this->dsnParser = $dsnParser ?? new DsnParser(self::DEFAULT_SCHEME_MAP);
public function __construct(
private readonly array $typesConfig = [],
DsnParser|null $dsnParser = null,
) {
$this->dsnParser = $dsnParser ?? new DsnParser(self::DEFAULT_SCHEME_MAP);
}

/**
Expand All @@ -67,7 +65,7 @@ public function __construct(array $typesConfig, ?DsnParser $dsnParser = null)
*
* @return Connection
*/
public function createConnection(array $params, ?Configuration $config = null, ?EventManager $eventManager = null, array $mappingTypes = [])
public function createConnection(array $params, Configuration|null $config = null, EventManager|null $eventManager = null, array $mappingTypes = [])
{
if (! method_exists(Connection::class, 'getEventManager') && $eventManager !== null) {
throw new InvalidArgumentException('Passing an EventManager instance is not supported with DBAL > 3');
Expand Down
16 changes: 6 additions & 10 deletions src/Controller/ProfilerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@
/** @internal */
class ProfilerController
{
private Environment $twig;
private ConnectionRegistry $registry;
private Profiler $profiler;

public function __construct(Environment $twig, ConnectionRegistry $registry, Profiler $profiler)
{
$this->twig = $twig;
$this->registry = $registry;
$this->profiler = $profiler;
public function __construct(
private readonly Environment $twig,
private readonly ConnectionRegistry $registry,
private readonly Profiler $profiler,
) {
}

/**
Expand Down Expand Up @@ -73,7 +69,7 @@ public function explainAction($token, $connectionName, $query)
} else {
$results = $this->explainOtherPlatform($connection, $query);
}
} catch (Throwable $e) {
} catch (Throwable) {
return new Response('This query cannot be explained.');
}

Expand Down
19 changes: 8 additions & 11 deletions src/DataCollector/DoctrineDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,23 @@
*/
class DoctrineDataCollector extends BaseCollector
{
private ManagerRegistry $registry;
private ?int $invalidEntityCount = null;
private int|null $invalidEntityCount = null;

/**
* @var mixed[][]|null
* @phpstan-var ?array<string, list<QueryType&array{count: int, index: int, executionPercent?: float}>>
*/
private ?array $groupedQueries = null;

private bool $shouldValidateSchema;

public function __construct(ManagerRegistry $registry, bool $shouldValidateSchema = true, ?DebugDataHolder $debugDataHolder = null)
{
$this->registry = $registry;
$this->shouldValidateSchema = $shouldValidateSchema;
private array|null $groupedQueries = null;

public function __construct(
private readonly ManagerRegistry $registry,
private readonly bool $shouldValidateSchema = true,
DebugDataHolder|null $debugDataHolder = null,
) {
parent::__construct($registry, $debugDataHolder);
}

public function collect(Request $request, Response $response, ?Throwable $exception = null): void
public function collect(Request $request, Response $response, Throwable|null $exception = null): void
{
parent::collect($request, $response, $exception);

Expand Down
Loading

0 comments on commit 24411a4

Please sign in to comment.