From 2ec2030ab2b5eb14157ec8307286a352c898dc97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 12 Oct 2024 15:40:48 +0200 Subject: [PATCH 1/6] Experiment with literalinclude I think it would be great to use literalinclude for big code snippets, because our IDEs could warn us about issues, and it would be easily to showcase our coding standard. Before we do that though, let us validate that it renders as expected. I have picked a complex example where we have a configuration block. --- .../working-with-indexed-associations.rst | 167 +----------------- .../Market-annotations.php | 74 ++++++++ .../Market.php | 68 +++++++ .../market.xml | 16 ++ .../market.yaml | 15 ++ 5 files changed, 181 insertions(+), 159 deletions(-) create mode 100644 docs/en/tutorials/working-with-indexed-associations/Market-annotations.php create mode 100644 docs/en/tutorials/working-with-indexed-associations/Market.php create mode 100644 docs/en/tutorials/working-with-indexed-associations/market.xml create mode 100644 docs/en/tutorials/working-with-indexed-associations/market.yaml diff --git a/docs/en/tutorials/working-with-indexed-associations.rst b/docs/en/tutorials/working-with-indexed-associations.rst index c4099eb5589..81032ee8e4a 100644 --- a/docs/en/tutorials/working-with-indexed-associations.rst +++ b/docs/en/tutorials/working-with-indexed-associations.rst @@ -31,169 +31,18 @@ You can map indexed associations by adding: The code and mappings for the Market entity looks like this: .. configuration-block:: - .. code-block:: attribute - - */ - #[OneToMany(targetEntity: Stock::class, mappedBy: 'market', indexBy: 'symbol')] - private Collection $stocks; - - public function __construct(string $name) - { - $this->name = $name; - $this->stocks = new ArrayCollection(); - } - - public function getId(): int|null - { - return $this->id; - } - - public function getName(): string - { - return $this->name; - } - - public function addStock(Stock $stock): void - { - $this->stocks[$stock->getSymbol()] = $stock; - } + .. literalinclude:: working-with-indexed-associations/Market.php + :language: attribute - public function getStock(string $symbol): Stock - { - if (!isset($this->stocks[$symbol])) { - throw new \InvalidArgumentException("Symbol is not traded on this market."); - } - - return $this->stocks[$symbol]; - } - - /** @return array */ - public function getStocks(): array - { - return $this->stocks->toArray(); - } - } - - .. code-block:: annotation - - - */ - private Collection $stocks; - - public function __construct($name) - { - $this->name = $name; - $this->stocks = new ArrayCollection(); - } - - public function getId(): int|null - { - return $this->id; - } - - public function getName(): string - { - return $this->name; - } - - public function addStock(Stock $stock): void - { - $this->stocks[$stock->getSymbol()] = $stock; - } - - public function getStock($symbol): Stock - { - if (!isset($this->stocks[$symbol])) { - throw new \InvalidArgumentException("Symbol is not traded on this market."); - } - - return $this->stocks[$symbol]; - } - - /** @return array */ - public function getStocks(): array - { - return $this->stocks->toArray(); - } - } - - .. code-block:: xml - - - - - - - - - - - - - - - - .. code-block:: yaml - - Doctrine\Tests\Models\StockExchange\Market: - type: entity - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type:string - oneToMany: - stocks: - targetEntity: Stock - mappedBy: market - indexBy: symbol Inside the ``addStock()`` method you can see how we directly set the key of the association to the symbol, so that we can work with the indexed association directly after invoking ``addStock()``. Inside ``getStock($symbol)`` diff --git a/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php b/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php new file mode 100644 index 00000000000..798b49d1d02 --- /dev/null +++ b/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php @@ -0,0 +1,74 @@ + + */ + private Collection $stocks; + + public function __construct($name) + { + $this->name = $name; + $this->stocks = new ArrayCollection(); + } + + public function getId(): int|null + { + return $this->id; + } + + public function getName(): string + { + return $this->name; + } + + public function addStock(Stock $stock): void + { + $this->stocks[$stock->getSymbol()] = $stock; + } + + public function getStock($symbol): Stock + { + if (!isset($this->stocks[$symbol])) { + throw new InvalidArgumentException("Symbol is not traded on this market."); + } + + return $this->stocks[$symbol]; + } + + /** @return array */ + public function getStocks(): array + { + return $this->stocks->toArray(); + } +} diff --git a/docs/en/tutorials/working-with-indexed-associations/Market.php b/docs/en/tutorials/working-with-indexed-associations/Market.php new file mode 100644 index 00000000000..bb16d3902b3 --- /dev/null +++ b/docs/en/tutorials/working-with-indexed-associations/Market.php @@ -0,0 +1,68 @@ + */ + #[OneToMany(targetEntity: Stock::class, mappedBy: 'market', indexBy: 'symbol')] + private Collection $stocks; + + public function __construct(string $name) + { + $this->name = $name; + $this->stocks = new ArrayCollection(); + } + + public function getId(): int|null + { + return $this->id; + } + + public function getName(): string + { + return $this->name; + } + + public function addStock(Stock $stock): void + { + $this->stocks[$stock->getSymbol()] = $stock; + } + + public function getStock(string $symbol): Stock + { + if (! isset($this->stocks[$symbol])) { + throw new InvalidArgumentException('Symbol is not traded on this market.'); + } + + return $this->stocks[$symbol]; + } + + /** @return array */ + public function getStocks(): array + { + return $this->stocks->toArray(); + } +} diff --git a/docs/en/tutorials/working-with-indexed-associations/market.xml b/docs/en/tutorials/working-with-indexed-associations/market.xml new file mode 100644 index 00000000000..3fc9fa2a857 --- /dev/null +++ b/docs/en/tutorials/working-with-indexed-associations/market.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + diff --git a/docs/en/tutorials/working-with-indexed-associations/market.yaml b/docs/en/tutorials/working-with-indexed-associations/market.yaml new file mode 100644 index 00000000000..b7c8132e090 --- /dev/null +++ b/docs/en/tutorials/working-with-indexed-associations/market.yaml @@ -0,0 +1,15 @@ +Doctrine\Tests\Models\StockExchange\Market: + type: entity + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + type:string + oneToMany: + stocks: + targetEntity: Stock + mappedBy: market + indexBy: symbol From bd20df104363ae7e6bb4a155efcb7c570850bd72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 12:47:29 +0200 Subject: [PATCH 2/6] Bump doctrine/.github from 5.1.0 to 5.2.0 (#11671) --- .github/workflows/coding-standards.yml | 2 +- .github/workflows/documentation.yml | 2 +- .github/workflows/release-on-milestone-closed.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 390bdb5afc2..e0e880ef39f 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -24,4 +24,4 @@ on: jobs: coding-standards: - uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.1.0" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.2.0" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index e9b2c71857d..bf2ba69d770 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -17,4 +17,4 @@ on: jobs: documentation: name: "Documentation" - uses: "doctrine/.github/.github/workflows/documentation.yml@5.1.0" + uses: "doctrine/.github/.github/workflows/documentation.yml@5.2.0" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index d54a784ebe5..f8bd8bce82e 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -7,7 +7,7 @@ on: jobs: release: - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.1.0" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.2.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} From 32682aa14d14bf2ddded8719ec825bb82e4768f0 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 13 Oct 2024 21:17:33 +0200 Subject: [PATCH 3/6] Fix PHPUnit deprecations --- .../ORM/Cache/DefaultCacheFactoryTest.php | 12 ++++----- ...ReadWriteCachedCollectionPersisterTest.php | 4 +-- ...rictReadWriteCachedEntityPersisterTest.php | 2 +- .../ReadWriteCachedEntityPersisterTest.php | 18 ++++++------- .../ORM/Functional/PostLoadEventTest.php | 27 +++++++------------ tests/Tests/ORM/Functional/SQLFilterTest.php | 18 ++++++------- .../ORM/Functional/Ticket/DDC2359Test.php | 10 +++---- .../ORM/Hydration/ObjectHydratorTest.php | 4 +-- .../Internal/HydrationCompleteHandlerTest.php | 8 +++--- .../Tests/ORM/LazyCriteriaCollectionTest.php | 14 +++++----- .../ORM/Mapping/ClassMetadataFactoryTest.php | 2 +- .../ReflectionPropertiesGetterTest.php | 4 +-- tests/Tests/ORM/Proxy/ProxyFactoryTest.php | 8 +++--- .../ORM/Query/SqlExpressionVisitorTest.php | 2 +- .../DefaultRepositoryFactoryTest.php | 12 ++++----- 15 files changed, 68 insertions(+), 77 deletions(-) diff --git a/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php index d8427a7f966..0a3680d7140 100644 --- a/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -77,7 +77,7 @@ public function testBuildCachedEntityPersisterReadOnly(): void $this->factory->expects(self::once()) ->method('getRegion') ->with(self::equalTo($metadata->cache)) - ->will(self::returnValue($region)); + ->willReturn($region); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); @@ -97,7 +97,7 @@ public function testBuildCachedEntityPersisterReadWrite(): void $this->factory->expects(self::once()) ->method('getRegion') ->with(self::equalTo($metadata->cache)) - ->will(self::returnValue($region)); + ->willReturn($region); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); @@ -117,7 +117,7 @@ public function testBuildCachedEntityPersisterNonStrictReadWrite(): void $this->factory->expects(self::once()) ->method('getRegion') ->with(self::equalTo($metadata->cache)) - ->will(self::returnValue($region)); + ->willReturn($region); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); @@ -138,7 +138,7 @@ public function testBuildCachedCollectionPersisterReadOnly(): void $this->factory->expects(self::once()) ->method('getRegion') ->with(self::equalTo($mapping['cache'])) - ->will(self::returnValue($region)); + ->willReturn($region); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); @@ -159,7 +159,7 @@ public function testBuildCachedCollectionPersisterReadWrite(): void $this->factory->expects(self::once()) ->method('getRegion') ->with(self::equalTo($mapping['cache'])) - ->will(self::returnValue($region)); + ->willReturn($region); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); @@ -180,7 +180,7 @@ public function testBuildCachedCollectionPersisterNonStrictReadWrite(): void $this->factory->expects(self::once()) ->method('getRegion') ->with(self::equalTo($mapping['cache'])) - ->will(self::returnValue($region)); + ->willReturn($region); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); diff --git a/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index 66c51df0a0f..f06845db9f2 100644 --- a/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -253,7 +253,7 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue(null)); + ->willReturn(null); $this->collectionPersister->expects(self::once()) ->method('delete') @@ -278,7 +278,7 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue(null)); + ->willReturn(null); $this->collectionPersister->expects(self::once()) ->method('update') diff --git a/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php index 71ae563bdde..35ea9ca86b6 100644 --- a/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php +++ b/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php @@ -63,7 +63,7 @@ public function testInsertTransactionCommitShouldPutCache(): void $this->entityPersister->expects(self::once()) ->method('getInserts') - ->will(self::returnValue([$entity])); + ->willReturn([$entity]); $this->entityPersister->expects(self::once()) ->method('executeInserts'); diff --git a/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index b7c279c6d2b..e8f2e38db4c 100644 --- a/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -39,7 +39,7 @@ public function testDeleteShouldLockItem(): void $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue($lock)); + ->willReturn($lock); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -56,7 +56,7 @@ public function testUpdateShouldLockItem(): void $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue($lock)); + ->willReturn($lock); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -73,12 +73,12 @@ public function testUpdateTransactionRollBackShouldEvictItem(): void $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue($lock)); + ->willReturn($lock); $this->region->expects(self::once()) ->method('evict') ->with(self::equalTo($key)) - ->will(self::returnValue($lock)); + ->willReturn($lock); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -96,7 +96,7 @@ public function testDeleteTransactionRollBackShouldEvictItem(): void $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue($lock)); + ->willReturn($lock); $this->region->expects(self::once()) ->method('evict') @@ -121,7 +121,7 @@ public function testTransactionRollBackShouldClearQueue(): void $this->region->expects(self::exactly(2)) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue($lock)); + ->willReturn($lock); $this->region->expects(self::exactly(2)) ->method('evict') @@ -152,7 +152,7 @@ public function testTransactionCommitShouldClearQueue(): void $this->region->expects(self::exactly(2)) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue($lock)); + ->willReturn($lock); $this->region->expects(self::exactly(2)) ->method('evict') @@ -182,7 +182,7 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue(null)); + ->willReturn(null); $this->entityPersister->expects(self::once()) ->method('delete') @@ -206,7 +206,7 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) - ->will(self::returnValue(null)); + ->willReturn(null); $this->entityPersister->expects(self::once()) ->method('update') diff --git a/tests/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Tests/ORM/Functional/PostLoadEventTest.php index 7963ee89774..8d6ee3b9c15 100644 --- a/tests/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Tests/ORM/Functional/PostLoadEventTest.php @@ -35,8 +35,7 @@ public function testLoadedEntityUsingFindShouldTriggerEvent(): void // CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser $mockListener ->expects(self::exactly(2)) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager = $this->_em->getEventManager(); @@ -52,8 +51,7 @@ public function testLoadedEntityUsingQueryShouldTriggerEvent(): void // CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser $mockListener ->expects(self::exactly(2)) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager = $this->_em->getEventManager(); @@ -72,8 +70,7 @@ public function testLoadedAssociationToOneShouldTriggerEvent(): void // CmsUser (root), CmsAddress (ToOne inverse side), CmsEmail (joined association) $mockListener ->expects(self::exactly(3)) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager = $this->_em->getEventManager(); @@ -92,8 +89,7 @@ public function testLoadedAssociationToManyShouldTriggerEvent(): void // CmsUser (root), CmsAddress (ToOne inverse side), 2 CmsPhonenumber (joined association) $mockListener ->expects(self::exactly(4)) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager = $this->_em->getEventManager(); @@ -114,8 +110,7 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void $mockListener ->expects(self::never()) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager->addEventListener([Events::postLoad], $mockListener); @@ -128,8 +123,7 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void $mockListener2 ->expects(self::exactly(2)) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager->addEventListener([Events::postLoad], $mockListener2); @@ -146,8 +140,7 @@ public function testLoadedProxyPartialShouldTriggerEvent(): void // CmsUser (partially loaded), CmsAddress (inverse ToOne), 2 CmsPhonenumber $mockListener ->expects(self::exactly(4)) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager->addEventListener([Events::postLoad], $mockListener); @@ -166,8 +159,7 @@ public function testLoadedProxyAssociationToOneShouldTriggerEvent(): void // CmsEmail (proxy) $mockListener ->expects(self::exactly(1)) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager = $this->_em->getEventManager(); @@ -187,8 +179,7 @@ public function testLoadedProxyAssociationToManyShouldTriggerEvent(): void // 2 CmsPhonenumber (proxy) $mockListener ->expects(self::exactly(2)) - ->method('postLoad') - ->will(self::returnValue(true)); + ->method('postLoad'); $eventManager = $this->_em->getEventManager(); diff --git a/tests/Tests/ORM/Functional/SQLFilterTest.php b/tests/Tests/ORM/Functional/SQLFilterTest.php index 8abb2b6636a..a4c8823c834 100644 --- a/tests/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Tests/ORM/Functional/SQLFilterTest.php @@ -255,7 +255,7 @@ private function addMockFilterCollection(EntityManagerInterface $em): FilterColl $em->expects(self::any()) ->method('getFilters') - ->will(self::returnValue($filterCollection)); + ->willReturn($filterCollection); return $filterCollection; } @@ -267,12 +267,12 @@ public function testSQLFilterGetSetParameter(): void $conn->expects(self::once()) ->method('quote') ->with(self::equalTo('en')) - ->will(self::returnValue("'en'")); + ->willReturn("'en'"); $em = $this->getMockEntityManager(); $em->expects(self::once()) ->method('getConnection') - ->will(self::returnValue($conn)); + ->willReturn($conn); $filterCollection = $this->addMockFilterCollection($em); $filterCollection @@ -298,7 +298,7 @@ public function testSQLFilterGetConnection(): void $em = $this->getMockEntityManager(); $em->expects(self::once()) ->method('getConnection') - ->will(self::returnValue($conn)); + ->willReturn($conn); $filter = new MyLocaleFilter($em); @@ -315,12 +315,12 @@ public function testSQLFilterSetParameterInfersType(): void $conn->expects(self::once()) ->method('quote') ->with(self::equalTo('en')) - ->will(self::returnValue("'en'")); + ->willReturn("'en'"); $em = $this->getMockEntityManager(); $em->expects(self::once()) ->method('getConnection') - ->will(self::returnValue($conn)); + ->willReturn($conn); $filterCollection = $this->addMockFilterCollection($em); $filterCollection @@ -339,13 +339,13 @@ public function testSQLFilterSetArrayParameterInfersType(): void // Setup mock connection $conn = $this->getMockConnection(); $conn->method('quote') - ->will(self::returnCallback(static function ($value) { + ->willReturnCallback(static function ($value) { return "'" . $value . "'"; - })); + }); $em = $this->getMockEntityManager(); $em->method('getConnection') - ->will(self::returnValue($conn)); + ->willReturn($conn); $filterCollection = $this->addMockFilterCollection($em); $filterCollection diff --git a/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php index 29f82d0c56d..882f6bcee60 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -45,15 +45,15 @@ public function testIssue(): void $configuration ->method('getMetadataDriverImpl') - ->will(self::returnValue($mockDriver)); + ->willReturn($mockDriver); - $entityManager->expects(self::any())->method('getConfiguration')->will(self::returnValue($configuration)); - $entityManager->expects(self::any())->method('getConnection')->will(self::returnValue($connection)); + $entityManager->expects(self::any())->method('getConfiguration')->willReturn($configuration); + $entityManager->expects(self::any())->method('getConnection')->willReturn($connection); $entityManager ->method('getEventManager') - ->will(self::returnValue($this->createMock(EventManager::class))); + ->willReturn($this->createMock(EventManager::class)); - $metadataFactory->method('newClassMetadataInstance')->will(self::returnValue($mockMetadata)); + $metadataFactory->method('newClassMetadataInstance')->willReturn($mockMetadata); $metadataFactory->expects(self::once())->method('wakeupReflection'); $metadataFactory->setEntityManager($entityManager); diff --git a/tests/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Tests/ORM/Hydration/ObjectHydratorTest.php index 37c36d18a8e..712a8cf411c 100644 --- a/tests/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -1036,7 +1036,7 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void $proxyFactory->expects(self::once()) ->method('getProxy') ->with(self::equalTo(ECommerceShipping::class), ['id' => 42]) - ->will(self::returnValue($proxyInstance)); + ->willReturn($proxyInstance); $this->entityManager->setProxyFactory($proxyFactory); @@ -1084,7 +1084,7 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE $proxyFactory->expects(self::once()) ->method('getProxy') ->with(self::equalTo(ECommerceShipping::class), ['id' => 42]) - ->will(self::returnValue($proxyInstance)); + ->willReturn($proxyInstance); $this->entityManager->setProxyFactory($proxyFactory); diff --git a/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index ff2e023791f..a9402481e9e 100644 --- a/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -53,7 +53,7 @@ public function testDefersPostLoadOfEntity(int $listenersFlag): void ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will(self::returnValue($listenersFlag)); + ->willReturn($listenersFlag); $this->handler->deferPostLoadInvoking($metadata, $entity); @@ -86,7 +86,7 @@ public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will(self::returnValue($listenersFlag)); + ->willReturn($listenersFlag); $this->handler->deferPostLoadInvoking($metadata, $entity); @@ -110,7 +110,7 @@ public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void ->expects(self::any()) ->method('getSubscribedSystems') ->with(self::logicalOr($metadata1, $metadata2)) - ->will(self::returnValue($listenersFlag)); + ->willReturn($listenersFlag); $this->handler->deferPostLoadInvoking($metadata1, $entity1); $this->handler->deferPostLoadInvoking($metadata2, $entity2); @@ -144,7 +144,7 @@ public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners(): voi ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will(self::returnValue(ListenersInvoker::INVOKE_NONE)); + ->willReturn(ListenersInvoker::INVOKE_NONE); $this->handler->deferPostLoadInvoking($metadata, $entity); diff --git a/tests/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Tests/ORM/LazyCriteriaCollectionTest.php index 02489d9f54e..6b8776c130d 100644 --- a/tests/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Tests/ORM/LazyCriteriaCollectionTest.php @@ -33,7 +33,7 @@ protected function setUp(): void public function testCountIsCached(): void { - $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(10)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->willReturn(10); self::assertSame(10, $this->lazyCriteriaCollection->count()); self::assertSame(10, $this->lazyCriteriaCollection->count()); @@ -42,7 +42,7 @@ public function testCountIsCached(): void public function testCountIsCachedEvenWithZeroResult(): void { - $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(0)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->willReturn(0); self::assertSame(0, $this->lazyCriteriaCollection->count()); self::assertSame(0, $this->lazyCriteriaCollection->count()); @@ -56,7 +56,7 @@ public function testCountUsesWrappedCollectionWhenInitialized(): void ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will(self::returnValue(['foo', 'bar', 'baz'])); + ->willReturn(['foo', 'bar', 'baz']); // should never call the persister's count $this->persister->expects(self::never())->method('count'); @@ -81,7 +81,7 @@ public function testMatchingUsesThePersisterOnlyOnce(): void ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will(self::returnValue([$foo, $bar, $baz])); + ->willReturn([$foo, $bar, $baz]); $criteria = new Criteria(); @@ -97,14 +97,14 @@ public function testMatchingUsesThePersisterOnlyOnce(): void public function testIsEmptyUsesCountWhenNotInitialized(): void { - $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(0)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->willReturn(0); self::assertTrue($this->lazyCriteriaCollection->isEmpty()); } public function testIsEmptyIsFalseIfCountIsNotZero(): void { - $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(1)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->willReturn(1); self::assertFalse($this->lazyCriteriaCollection->isEmpty()); } @@ -116,7 +116,7 @@ public function testIsEmptyUsesWrappedCollectionWhenInitialized(): void ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will(self::returnValue(['foo', 'bar', 'baz'])); + ->willReturn(['foo', 'bar', 'baz']); // should never call the persister's count $this->persister->expects(self::never())->method('count'); diff --git a/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 00f85b01f5d..bea5e2578da 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -320,7 +320,7 @@ public function testGetAllMetadataWorksWithBadConnection(): void $conn->expects(self::any()) ->method('getDatabasePlatform') - ->will(self::throwException(new Exception('Exception thrown in test when calling getDatabasePlatform'))); + ->willThrowException(new Exception('Exception thrown in test when calling getDatabasePlatform')); $cmf = new ClassMetadataFactory(); $cmf->setEntityManager($em); diff --git a/tests/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php b/tests/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php index d608b939efc..9d5271add83 100644 --- a/tests/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php +++ b/tests/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php @@ -101,10 +101,10 @@ public function testPropertyGetterWillSkipPropertiesNotRetrievedByTheRuntimeRefl ->expects(self::exactly(2)) ->method('getClass') ->with(self::logicalOr(ClassWithMixedProperties::class, ParentClass::class)) - ->will(self::returnValueMap([ + ->willReturnMap([ [ClassWithMixedProperties::class, new ReflectionClass(ClassWithMixedProperties::class)], [ParentClass::class, new ReflectionClass(ParentClass::class)], - ])); + ]); $reflectionService ->expects(self::atLeastOnce()) diff --git a/tests/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Tests/ORM/Proxy/ProxyFactoryTest.php index e6335c46c8f..1b622f814b7 100644 --- a/tests/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -76,7 +76,7 @@ public function testReferenceProxyDelegatesLoadingToThePersister(): void ->expects(self::atLeastOnce()) ->method('loadById') ->with(self::equalTo($identifier)) - ->will(self::returnValue($proxy)); + ->willReturn($proxy); $proxy->getDescription(); } @@ -133,7 +133,7 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void $persister ->expects(self::atLeastOnce()) ->method('load') - ->will(self::returnValue(null)); + ->willReturn(null); try { $proxy->getDescription(); @@ -160,7 +160,7 @@ public function testExceptionOnProxyLoadingDoesNotMarkTheProxyAsInitialized(): v $persister ->expects(self::atLeastOnce()) ->method('load') - ->will(self::throwException($exception)); + ->willThrowException($exception); try { $proxy->getDescription(); @@ -186,7 +186,7 @@ public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void $persister ->expects(self::atLeastOnce()) ->method('load') - ->will(self::returnValue(null)); + ->willReturn(null); try { $cloned = clone $proxy; diff --git a/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php b/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php index 140e0a540c8..680d8ca1ccd 100644 --- a/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php +++ b/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php @@ -41,7 +41,7 @@ public function testWalkNotCompositeExpression(): void $this->persister ->expects(self::once()) ->method('getSelectConditionStatementSQL') - ->will(self::returnValue('dummy expression')); + ->willReturn('dummy expression'); $expr = $this->visitor->walkCompositeExpression( $cb->not( diff --git a/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index cfc2fc4f85d..f4260d232a7 100644 --- a/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -40,7 +40,7 @@ protected function setUp(): void $this->configuration ->expects(self::any()) ->method('getDefaultRepositoryClassName') - ->will(self::returnValue(DDC869PaymentRepository::class)); + ->willReturn(DDC869PaymentRepository::class); } public function testCreatesRepositoryFromDefaultRepositoryClass(): void @@ -48,7 +48,7 @@ public function testCreatesRepositoryFromDefaultRepositoryClass(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); + ->willReturnCallback(Closure::fromCallable([$this, 'buildClassMetadata'])); self::assertInstanceOf( DDC869PaymentRepository::class, @@ -61,7 +61,7 @@ public function testCreatedRepositoriesAreCached(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); + ->willReturnCallback(Closure::fromCallable([$this, 'buildClassMetadata'])); self::assertSame( $this->repositoryFactory->getRepository($this->entityManager, self::class), @@ -77,7 +77,7 @@ public function testCreatesRepositoryFromCustomClassMetadata(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnValue($customMetadata)); + ->willReturn($customMetadata); self::assertInstanceOf( DDC753DefaultRepository::class, @@ -92,11 +92,11 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void $em1->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); + ->willReturnCallback(Closure::fromCallable([$this, 'buildClassMetadata'])); $em2->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); + ->willReturnCallback(Closure::fromCallable([$this, 'buildClassMetadata'])); $repo1 = $this->repositoryFactory->getRepository($em1, self::class); $repo2 = $this->repositoryFactory->getRepository($em2, self::class); From 4ff909044efb17ab33b7cc68e88572bbb7ce2a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 13 Oct 2024 21:45:35 +0200 Subject: [PATCH 4/6] Update README (#11673) --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 75b3c34a18f..752c2b2a0a2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -| [4.0.x][4.0] | [3.2.x][3.2] | [3.1.x][3.1] | [2.20.x][2.20] | [2.19.x][2.19] | +| [4.0.x][4.0] | [3.4.x][3.4] | [3.3.x][3.3] | [2.21.x][2.21] | [2.20.x][2.20] | |:------------------------------------------------------:|:------------------------------------------------------:|:------------------------------------------------------:|:--------------------------------------------------------:|:--------------------------------------------------------:| -| [![Build status][4.0 image]][4.0] | [![Build status][3.2 image]][3.2] | [![Build status][3.1 image]][3.1] | [![Build status][2.20 image]][2.20] | [![Build status][2.19 image]][2.19] | -| [![Coverage Status][4.0 coverage image]][4.0 coverage] | [![Coverage Status][3.2 coverage image]][3.2 coverage] | [![Coverage Status][3.1 coverage image]][3.1 coverage] | [![Coverage Status][2.20 coverage image]][2.20 coverage] | [![Coverage Status][2.19 coverage image]][2.19 coverage] | +| [![Build status][4.0 image]][4.0] | [![Build status][3.4 image]][3.4] | [![Build status][3.3 image]][3.3] | [![Build status][2.21 image]][2.21] | [![Build status][2.20 image]][2.20] | +| [![Coverage Status][4.0 coverage image]][4.0 coverage] | [![Coverage Status][3.4 coverage image]][3.4 coverage] | [![Coverage Status][3.3 coverage image]][3.3 coverage] | [![Coverage Status][2.21 coverage image]][2.21 coverage] | [![Coverage Status][2.20 coverage image]][2.20 coverage] | [

πŸ‡ΊπŸ‡¦ UKRAINE NEEDS YOUR HELP NOW!

](https://www.doctrine-project.org/stop-war.html) @@ -22,19 +22,19 @@ without requiring unnecessary code duplication. [4.0]: https://github.com/doctrine/orm/tree/4.0.x [4.0 coverage image]: https://codecov.io/gh/doctrine/orm/branch/4.0.x/graph/badge.svg [4.0 coverage]: https://codecov.io/gh/doctrine/orm/branch/4.0.x - [3.2 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.2.x - [3.2]: https://github.com/doctrine/orm/tree/3.2.x - [3.2 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.2.x/graph/badge.svg - [3.2 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.2.x - [3.1 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.1.x - [3.1]: https://github.com/doctrine/orm/tree/3.1.x - [3.1 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.1.x/graph/badge.svg - [3.1 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.1.x + [3.4 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.4.x + [3.4]: https://github.com/doctrine/orm/tree/3.4.x + [3.4 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.4.x/graph/badge.svg + [3.4 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.4.x + [3.3 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.3.x + [3.3]: https://github.com/doctrine/orm/tree/3.3.x + [3.3 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.3.x/graph/badge.svg + [3.3 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.3.x + [2.21 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.21.x + [2.21]: https://github.com/doctrine/orm/tree/2.21.x + [2.21 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.21.x/graph/badge.svg + [2.21 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.21.x [2.20 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.20.x [2.20]: https://github.com/doctrine/orm/tree/2.20.x [2.20 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.20.x/graph/badge.svg [2.20 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.20.x - [2.19 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.19.x - [2.19]: https://github.com/doctrine/orm/tree/2.19.x - [2.19 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.19.x/graph/badge.svg - [2.19 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.19.x From f53350934f3afd7fbecaa90315965448b05d1419 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 13 Oct 2024 22:04:07 +0200 Subject: [PATCH 5/6] Psalm 5.26.1 (#11677) --- composer.json | 2 +- psalm-baseline.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 68d8961f52d..6001689c408 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "symfony/cache": "^4.4 || ^5.4 || ^6.4 || ^7.0", "symfony/var-exporter": "^4.4 || ^5.4 || ^6.2 || ^7.0", "symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0", - "vimeo/psalm": "4.30.0 || 5.24.0" + "vimeo/psalm": "4.30.0 || 5.26.1" }, "conflict": { "doctrine/annotations": "<1.13 || >= 3.0" diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 28ed8aab049..b8655116282 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + From 982d6060a3c71574a986da0f0e466669052791a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 08:56:04 +0200 Subject: [PATCH 6/6] Bump doctrine/.github from 5.1.0 to 5.2.0 (#11680)