From 724f0b35c04a3230d6511a1cdcea61a86a09ac8b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 4 Feb 2024 10:13:42 +0100 Subject: [PATCH 1/3] Add support to doctrine ORM 3 and drop support for Doctrin ORM 2 --- composer.json | 2 +- src/Doctrine/NoDbNameConnectionFactory.php | 2 +- src/Doctrine/Type/ChronosDateTimeType.php | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 6a5c7c2..c43d750 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "ext-fileinfo": "*", "akrabat/ip-address-middleware": "^2.1", "cakephp/chronos": "^3.0.2", - "doctrine/orm": "^2.17", + "doctrine/orm": "^3.0", "endroid/qr-code": "^4.8", "fig/http-message-util": "^1.1", "guzzlehttp/guzzle": "^7.8", diff --git a/src/Doctrine/NoDbNameConnectionFactory.php b/src/Doctrine/NoDbNameConnectionFactory.php index d59558e..316be0e 100644 --- a/src/Doctrine/NoDbNameConnectionFactory.php +++ b/src/Doctrine/NoDbNameConnectionFactory.php @@ -19,6 +19,6 @@ public function __invoke(ContainerInterface $container): Connection $params = $conn->getParams(); unset($params['dbname']); - return new Connection($params, $conn->getDriver(), $conn->getConfiguration(), $em->getEventManager()); + return new Connection($params, $conn->getDriver(), $conn->getConfiguration()); } } diff --git a/src/Doctrine/Type/ChronosDateTimeType.php b/src/Doctrine/Type/ChronosDateTimeType.php index 51b986a..ba73415 100644 --- a/src/Doctrine/Type/ChronosDateTimeType.php +++ b/src/Doctrine/Type/ChronosDateTimeType.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\DateTimeImmutableType; +use Doctrine\DBAL\Types\Exception\InvalidType; class ChronosDateTimeType extends DateTimeImmutableType { @@ -48,10 +49,6 @@ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform) return $value->format($platform->getDateTimeFormatString()); } - throw ConversionException::conversionFailedInvalidType( - $value, - $this->getName(), - ['null', DateTimeInterface::class], - ); + throw InvalidType::new($value, $this->getName(), ['null', DateTimeInterface::class]); } } From 0a99767e35a91bd3dd75d8efdf760ece89a6ecfd Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 17 Feb 2024 09:12:03 +0100 Subject: [PATCH 2/3] Fix tests for Doctrine ORM 3.0 --- test/Doctrine/EntityRepositoryFactoryTest.php | 2 +- test/Doctrine/NoDbNameConnectionFactoryTest.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Doctrine/EntityRepositoryFactoryTest.php b/test/Doctrine/EntityRepositoryFactoryTest.php index 55612ad..63ff33f 100644 --- a/test/Doctrine/EntityRepositoryFactoryTest.php +++ b/test/Doctrine/EntityRepositoryFactoryTest.php @@ -47,7 +47,7 @@ public function setUp(): void public function createsRequestedRepositoryClass(string $repoClass): void { $this->em->expects($this->once())->method('getClassMetadata')->with(stdClass::class)->willReturn( - $this->createMock(ClassMetadata::class), + new ClassMetadata(stdClass::class), ); $repoInstance = EntityRepositoryFactory::{stdClass::class}($this->container, $repoClass); diff --git a/test/Doctrine/NoDbNameConnectionFactoryTest.php b/test/Doctrine/NoDbNameConnectionFactoryTest.php index fbea7b3..c3d18b4 100644 --- a/test/Doctrine/NoDbNameConnectionFactoryTest.php +++ b/test/Doctrine/NoDbNameConnectionFactoryTest.php @@ -41,7 +41,6 @@ public function newConnectionIsCreatedRemovingDbNameFromOriginalConnectionParams $this->originalConn->expects($this->once())->method('getParams')->willReturn($params); $this->originalConn->expects($this->once())->method('getDriver')->willReturn($this->createMock(Driver::class)); $this->originalConn->expects($this->once())->method('getConfiguration')->willReturn(new Configuration()); - $this->em->expects($this->once())->method('getEventManager')->willReturn(null); $this->em->expects($this->once())->method('getConnection')->willReturn($this->originalConn); $this->container->expects($this->once())->method('get')->with(EntityManager::class)->willReturn($this->em); From d94212b4a5086ed10a9768df395bf966f442e8cc Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 17 Feb 2024 09:13:03 +0100 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8299bb9..699e896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ## [Unreleased] ### Added * Add new `RequestIdMiddleware`. +* Add support for Doctrine ORM 3.0.0 ### Changed * Update dependencies @@ -20,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * Remove support for non-URL-encoded credentials in redis URIs. * Remove `json_decode` and `json_encode` functions. * Remove support for openswoole. +* Drop support for Doctrine ORM 2.x ### Fixed * *Nothing*