Skip to content
Merged
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
6 changes: 2 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
dependencies:
- "highest"
stability:
Expand All @@ -52,7 +50,7 @@ jobs:
# Tests the lowest set of dependencies
- dependencies: "lowest"
stability: "stable"
php-version: "8.1"
php-version: "8.4"

# Test LTS
- symfony-require: "6.4.*"
Expand Down
8 changes: 8 additions & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Compatibility
Configuring caching options to use services backed by `doctrine/cache` is no
longer supported. Migrate to PSR-6 services instead.

The minimum required PHP version is now 8.4.

Support for the following major versions of the following packages has been dropped:

- `doctrine/dbal` 3
Expand Down Expand Up @@ -73,6 +75,12 @@ You should use stop passing an event manager argument.
+ $connectionFactory->createConnection($params, $config, $mappingTypes)
```

Type declarations
-----------------

Native type declarations have been added to all constants, properties, and
methods.

Types
-----

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
"homepage": "https://www.doctrine-project.org",
"require": {
"php": "^8.1",
"php": "^8.4",
"doctrine/dbal": "^4.0",
"doctrine/persistence": "^4",
"doctrine/sql-formatter": "^1.0.1",
Expand Down
4 changes: 1 addition & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

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

<file>config</file>
<file>src</file>
<file>tests</file>

<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/> <!-- we can do it in doctrine-bundle 3.0-->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/> <!-- we can do it in doctrine-bundle 3.0 -->
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/>
</rule>
Expand Down
9 changes: 2 additions & 7 deletions src/Command/DoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ public function __construct(

/**
* Get a doctrine dbal connection by symfony name.
*
* @param string $name
*
* @return Connection
*/
protected function getDoctrineConnection($name)
protected function getDoctrineConnection(string $name): Connection
{
return $this->getDoctrine()->getConnection($name);
}

/** @return ManagerRegistry */
protected function getDoctrine()
protected function getDoctrine(): ManagerRegistry
{
return $this->doctrine;
}
Expand Down
7 changes: 3 additions & 4 deletions src/Command/DropDatabaseDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
*/
class DropDatabaseDoctrineCommand extends DoctrineCommand
{
public const RETURN_CODE_NOT_DROP = 1;
public const int RETURN_CODE_NOT_DROP = 1;

public const RETURN_CODE_NO_FORCE = 2;
public const int RETURN_CODE_NO_FORCE = 2;

/** @return void */
protected function configure()
protected function configure(): void
{
$this
->setName('doctrine:database:drop')
Expand Down
6 changes: 2 additions & 4 deletions src/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class ConnectionFactory
{
/** @internal */
public const DEFAULT_SCHEME_MAP = [
public const array DEFAULT_SCHEME_MAP = [
'db2' => 'ibm_db2',
'mssql' => 'pdo_sqlsrv',
'mysql' => 'pdo_mysql',
Expand Down Expand Up @@ -59,14 +59,12 @@ public function __construct(
* @param mixed[] $params
* @param array<string, string> $mappingTypes
* @phpstan-param Params $params
*
* @return Connection
*/
public function createConnection(
array $params,
Configuration|null $config = null,
array $mappingTypes = [],
) {
): Connection {
if (! $this->initialized) {
$this->initializeTypes();
}
Expand Down
6 changes: 2 additions & 4 deletions src/Controller/ProfilerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ public function __construct(
/**
* Renders the profiler panel for the given token.
*
* @param string $token The profiler token
* @param string $connectionName
* @param int $query
* @param string $token The profiler token
*
* @return Response A Response instance
*/
public function explainAction($token, $connectionName, $query)
public function explainAction(string $token, string $connectionName, int $query): Response
{
$this->profiler->disable();

Expand Down
28 changes: 11 additions & 17 deletions src/DataCollector/DoctrineDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,37 +186,33 @@ public function collect(Request $request, Response $response, Throwable|null $ex
}

/** @return array<string, array<class-string, array{class: class-string, file: false|string, line: false|int}>> */
public function getEntities()
public function getEntities(): array
{
return $this->data['entities'];
}

/** @return array<string, array<string, list<string>>> */
public function getMappingErrors()
public function getMappingErrors(): array
{
return $this->data['errors'];
}

/** @return int */
public function getCacheHitsCount()
public function getCacheHitsCount(): int
{
return $this->data['caches']['counts']['hits'];
}

/** @return int */
public function getCachePutsCount()
public function getCachePutsCount(): int
{
return $this->data['caches']['counts']['puts'];
}

/** @return int */
public function getCacheMissesCount()
public function getCacheMissesCount(): int
{
return $this->data['caches']['counts']['misses'];
}

/** @return bool */
public function getCacheEnabled()
public function getCacheEnabled(): bool
{
return $this->data['caches']['enabled'];
}
Expand All @@ -225,19 +221,18 @@ public function getCacheEnabled()
* @return array<string, array<string, int>>
* @phpstan-return array<"puts"|"hits"|"misses", array<string, int>>
*/
public function getCacheRegions()
public function getCacheRegions(): array
{
return $this->data['caches']['regions'];
}

/** @return array<string, int> */
public function getCacheCounts()
public function getCacheCounts(): array
{
return $this->data['caches']['counts'];
}

/** @return int */
public function getInvalidEntityCount()
public function getInvalidEntityCount(): int
{
return $this->invalidEntityCount ??= array_sum(array_map('count', $this->data['errors']));
}
Expand Down Expand Up @@ -266,7 +261,7 @@ public function getManagedEntityCountByClass(): array
* @return string[][]
* @phpstan-return array<string, list<QueryType&array{count: int, index: int, executionPercent?: float}>>
*/
public function getGroupedQueries()
public function getGroupedQueries(): array
{
if ($this->groupedQueries !== null) {
return $this->groupedQueries;
Expand Down Expand Up @@ -319,8 +314,7 @@ private function executionTimePercentage(float $executionTimeMS, float $totalExe
return $executionTimeMS / $totalExecutionTimeMS * 100;
}

/** @return int */
public function getGroupedQueryCount()
public function getGroupedQueryCount(): int
{
$count = 0;
foreach ($this->getGroupedQueries() as $connectionGroupedQueries) {
Expand Down
3 changes: 1 addition & 2 deletions src/Dbal/BlacklistSchemaAssetFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public function __construct(
) {
}

/** @param string|AbstractAsset $assetName */
public function __invoke($assetName): bool
public function __invoke(string|AbstractAsset $assetName): bool
{
if ($assetName instanceof AbstractAsset) {
$assetName = $assetName->getName();
Expand Down
3 changes: 1 addition & 2 deletions src/Dbal/SchemaAssetsFilterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public function __construct(
) {
}

/** @param string|AbstractAsset $assetName */
public function __invoke($assetName): bool
public function __invoke(string|AbstractAsset $assetName): bool
{
foreach ($this->schemaAssetFilters as $schemaAssetFilter) {
if ($schemaAssetFilter($assetName) === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
class CacheSchemaSubscriberPass implements CompilerPassInterface
{
/** @return void */
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (! $container->hasDefinition('doctrine.orm.listeners.doctrine_dbal_cache_adapter_schema_listener')) {
return;
Expand Down
3 changes: 1 addition & 2 deletions src/DependencyInjection/Compiler/DbalSchemaFilterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
class DbalSchemaFilterPass implements CompilerPassInterface
{
/** @return void */
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$filters = $container->findTaggedServiceIds('doctrine.dbal.schema_filter');

Expand Down
18 changes: 5 additions & 13 deletions src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DoctrineOrmMappingsPass extends RegisterMappingsPass
* container.
* @param string[] $aliasMap Map of alias to namespace.
*/
public function __construct($driver, array $namespaces, array $managerParameters, $enabledParameter = false, array $aliasMap = [])
public function __construct(Definition|Reference $driver, array $namespaces, array $managerParameters, string|false $enabledParameter = false, array $aliasMap = [])
{
$managerParameters[] = 'doctrine.default_entity_manager';

Expand All @@ -60,10 +60,8 @@ public function __construct($driver, array $namespaces, array $managerParameters
* enable the mapping. Set to false to not do any check,
* optional.
* @param string[] $aliasMap Map of alias to namespace.
*
* @return self
*/
public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [], bool $enableXsdValidation = false)
public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], string|false $enabledParameter = false, array $aliasMap = [], bool $enableXsdValidation = false): self
{
$locator = new Definition(SymfonyFileLocator::class, [$namespaces, '.orm.xml']);
$driver = new Definition(XmlDriver::class, [$locator, XmlDriver::DEFAULT_FILE_EXTENSION, $enableXsdValidation]);
Expand All @@ -81,10 +79,8 @@ public static function createXmlMappingDriver(array $namespaces, array $managerP
* enable the mapping. Set to false to not do any check,
* optional.
* @param string[] $aliasMap Map of alias to namespace.
*
* @return self
*/
public static function createPhpMappingDriver(array $namespaces, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [])
public static function createPhpMappingDriver(array $namespaces, array $managerParameters = [], string|false $enabledParameter = false, array $aliasMap = []): self
{
$locator = new Definition(SymfonyFileLocator::class, [$namespaces, '.php']);
$driver = new Definition(PHPDriver::class, [$locator]);
Expand All @@ -103,10 +99,8 @@ public static function createPhpMappingDriver(array $namespaces, array $managerP
* enable the mapping. Set to false to not do any check,
* optional.
* @param string[] $aliasMap Map of alias to namespace.
*
* @return self
*/
public static function createAttributeMappingDriver(array $namespaces, array $directories, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [])
public static function createAttributeMappingDriver(array $namespaces, array $directories, array $managerParameters = [], string|false $enabledParameter = false, array $aliasMap = []): self
{
$driver = new Definition(AttributeDriver::class, [$directories]);

Expand All @@ -124,10 +118,8 @@ public static function createAttributeMappingDriver(array $namespaces, array $di
* enable the mapping. Set to false to not do any check,
* optional.
* @param string[] $aliasMap Map of alias to namespace.
*
* @return self
*/
public static function createStaticPhpMappingDriver(array $namespaces, array $directories, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [])
public static function createStaticPhpMappingDriver(array $namespaces, array $directories, array $managerParameters = [], string|false $enabledParameter = false, array $aliasMap = []): self
{
$driver = new Definition(StaticPHPDriver::class, [$directories]);

Expand Down
3 changes: 1 addition & 2 deletions src/DependencyInjection/Compiler/EntityListenerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class EntityListenerPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait;

/** @return void */
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$resolvers = $this->findAndSortTaggedServices('doctrine.orm.entity_listener', $container);

Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Compiler/IdGeneratorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

final class IdGeneratorPass implements CompilerPassInterface
{
public const ID_GENERATOR_TAG = 'doctrine.id_generator';
public const CONFIGURATION_TAG = 'doctrine.orm.configuration';
public const string ID_GENERATOR_TAG = 'doctrine.id_generator';
public const string CONFIGURATION_TAG = 'doctrine.orm.configuration';

public function process(ContainerBuilder $container): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

final class ServiceRepositoryCompilerPass implements CompilerPassInterface
{
public const REPOSITORY_SERVICE_TAG = 'doctrine.repository_service';
public const string REPOSITORY_SERVICE_TAG = 'doctrine.repository_service';

public function process(ContainerBuilder $container): void
{
Expand Down
Loading